#include <mach/rk29_camera.h> /* ddl@rock-chips.com : camera support */
#include <media/soc_camera.h> /* ddl@rock-chips.com : camera support */
#include <mach/vpu_mem.h>
+#include <mach/sram.h>
+#include <linux/regulator/rk29-pwm-regulator.h>
+#include <linux/regulator/machine.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#endif
#define PMEM_GPU_SIZE SZ_64M
#define PMEM_UI_SIZE SZ_32M
-#define PMEM_VPU_SIZE SZ_32M
-#define PMEM_CAM_SIZE 0x00c00000
+#define PMEM_VPU_SIZE SZ_64M
+#define PMEM_CAM_SIZE 0x01300000
#ifdef CONFIG_VIDEO_RK29_WORK_IPP
#define MEM_CAMIPP_SIZE SZ_4M
#else
#define MEM_FB_BASE (MEM_CAMIPP_BASE - MEM_FB_SIZE)
#define LINUX_SIZE (MEM_FB_BASE - RK29_SDRAM_PHYS)
+#define PREALLOC_WLAN_SEC_NUM 4
+#define PREALLOC_WLAN_BUF_NUM 160
+#define PREALLOC_WLAN_SECTION_HEADER 24
+
+#define WLAN_SECTION_SIZE_0 (PREALLOC_WLAN_BUF_NUM * 128)
+#define WLAN_SECTION_SIZE_1 (PREALLOC_WLAN_BUF_NUM * 128)
+#define WLAN_SECTION_SIZE_2 (PREALLOC_WLAN_BUF_NUM * 512)
+#define WLAN_SECTION_SIZE_3 (PREALLOC_WLAN_BUF_NUM * 1024)
+
+#define WLAN_SKB_BUF_NUM 16
+
+static struct sk_buff *wlan_static_skb[WLAN_SKB_BUF_NUM];
+
+struct wifi_mem_prealloc {
+ void *mem_ptr;
+ unsigned long size;
+};
+
extern struct sys_timer rk29_timer;
-int rk29_nand_io_init(void)
+static int rk29_nand_io_init(void)
{
return 0;
}
.io_init = rk29_nand_io_init,
};
-static struct rk29_gpio_bank rk29_gpiobankinit[] = {
- {
- .id = RK29_ID_GPIO0,
- .offset = RK29_GPIO0_BASE,
- },
- {
- .id = RK29_ID_GPIO1,
- .offset = RK29_GPIO1_BASE,
- },
- {
- .id = RK29_ID_GPIO2,
- .offset = RK29_GPIO2_BASE,
- },
- {
- .id = RK29_ID_GPIO3,
- .offset = RK29_GPIO3_BASE,
- },
- {
- .id = RK29_ID_GPIO4,
- .offset = RK29_GPIO4_BASE,
- },
- {
- .id = RK29_ID_GPIO5,
- .offset = RK29_GPIO5_BASE,
- },
- {
- .id = RK29_ID_GPIO6,
- .offset = RK29_GPIO6_BASE,
- },
-};
-
#ifdef CONFIG_FB_RK29
/*****************************************************************************************
* lcd devices
return ret;
}
-struct rk29lcd_info rk29_lcd_info = {
+static struct rk29lcd_info rk29_lcd_info = {
.txd_pin = LCD_TXD_PIN,
.clk_pin = LCD_CLK_PIN,
.cs_pin = LCD_CS_PIN,
gpio_direction_output(FB_LCD_CABC_EN_PIN, 0);
gpio_set_value(FB_LCD_CABC_EN_PIN, GPIO_LOW);
}
-
+
return ret;
}
-struct rk29fb_info rk29_fb_info = {
+static struct rk29fb_info rk29_fb_info = {
.fb_id = FB_ID,
.disp_on_pin = FB_DISPLAY_ON_PIN,
.disp_on_value = FB_DISPLAY_ON_VALUE,
};
/* rk29 fb resource */
-struct resource rk29_fb_resource[] = {
+static struct resource rk29_fb_resource[] = {
[0] = {
.name = "lcdc reg",
.start = RK29_LCDC_PHYS,
[2] = {
.name = "win1 buf",
.start = MEM_FB_BASE,
- .end = MEM_FB_BASE + MEM_FB_SIZE,
+ .end = MEM_FB_BASE + MEM_FB_SIZE - 1,
.flags = IORESOURCE_MEM,
},
};
.platform_data = &rk29_fb_info,
}
};
+
+struct platform_device rk29_device_dma_cpy = {
+ .name = "dma_memcpy",
+ .id = 4,
+
+};
+
#endif
static struct android_pmem_platform_data android_pmem_pdata = {
.name = "pmem_cam",
.start = PMEM_CAM_BASE,
.size = PMEM_CAM_SIZE,
- .no_allocator = 0,
+ .no_allocator = 1,
.cached = 1,
};
},
};
+static struct platform_device rk29_v4l2_output_devce = {
+ .name = "rk29_vout",
+};
/*HANNSTAR_P1003 touch*/
#if defined (CONFIG_HANNSTAR_P1003)
};
#endif
+#if defined (CONFIG_EETI_EGALAX)
+#define TOUCH_RESET_PIN RK29_PIN6_PC3
+#define TOUCH_INT_PIN RK29_PIN0_PA2
+static int EETI_EGALAX_init_platform_hw(void)
+{
+ if(gpio_request(TOUCH_RESET_PIN,NULL) != 0){
+ gpio_free(TOUCH_RESET_PIN);
+ printk("p1003_init_platform_hw gpio_request error\n");
+ return -EIO;
+ }
+
+ if(gpio_request(TOUCH_INT_PIN,NULL) != 0){
+ gpio_free(TOUCH_INT_PIN);
+ printk("p1003_init_platform_hw gpio_request error\n");
+ return -EIO;
+ }
+ gpio_pull_updown(TOUCH_INT_PIN, 1);
+ gpio_direction_output(TOUCH_RESET_PIN, 0);
+ msleep(500);
+ gpio_set_value(TOUCH_RESET_PIN,GPIO_LOW);
+ msleep(500);
+ gpio_set_value(TOUCH_RESET_PIN,GPIO_HIGH);
+
+ return 0;
+}
+
+
+static struct eeti_egalax_platform_data eeti_egalax_info = {
+ .model= 1003,
+ .init_platform_hw= EETI_EGALAX_init_platform_hw,
+
+};
+#endif
/*MMA8452 gsensor*/
#if defined (CONFIG_GS_MMA8452)
#define MMA8452_INT_PIN RK29_PIN0_PA3
-int mma8452_init_platform_hw(void)
+static int mma8452_init_platform_hw(void)
{
if(gpio_request(MMA8452_INT_PIN,NULL) != 0){
}
-struct mma8452_platform_data mma8452_info = {
+static struct mma8452_platform_data mma8452_info = {
.model= 8452,
.swap_xy = 0,
.init_platform_hw= mma8452_init_platform_hw,
};
#endif
+#if defined (CONFIG_BATTERY_BQ27510)
+#define DC_CHECK_PIN RK29_PIN4_PA1
+#define LI_LION_BAT_NUM 2
+static int bq27510_init_dc_check_pin(void){
+ if(gpio_request(DC_CHECK_PIN,"dc_check") != 0){
+ gpio_free(DC_CHECK_PIN);
+ printk("bq27510 init dc check pin request error\n");
+ return -EIO;
+ }
+ gpio_direction_input(DC_CHECK_PIN);
+ return 0;
+}
+
+struct bq27510_platform_data bq27510_info = {
+ .init_dc_check_pin = bq27510_init_dc_check_pin,
+ .dc_check_pin = DC_CHECK_PIN,
+ .bat_num = LI_LION_BAT_NUM,
+};
+#endif
/*****************************************************************************************
.type = "stc3100",
.addr = 0x70,
.flags = 0,
- },
+ },
#endif
#if defined (CONFIG_BATTERY_BQ27510)
{
.type = "bq27510",
.addr = 0x55,
.flags = 0,
+ .platform_data = &bq27510_info,
},
#endif
#if defined (CONFIG_RTC_HYM8563)
.type = "rtc_hym8563",
.addr = 0x51,
.flags = 0,
- ///.irq = RK2818_PIN_PA4,
+ .irq = RK29_PIN0_PA1,
},
#endif
#if defined (CONFIG_GS_MMA8452)
.platform_data = &mma8452_info,
},
#endif
-
-};
-#endif
-
-#ifdef CONFIG_I2C1_RK29
-static struct i2c_board_info __initdata board_i2c1_devices[] = {
-#if defined (CONFIG_RK1000_CONTROL1)
- {
- .type = "rk1000_control",
- .addr = 0x40,
- .flags = 0,
- },
-#endif
-#if defined (CONFIG_SENSORS_AK8973)
+#if defined (CONFIG_COMPASS_AK8973)
{
.type = "ak8973",
- .addr = 0x1c,
+ .addr = 0x1d,
.flags = 0,
- .irq = RK29_PIN4_PA1,
+ .irq = RK29_PIN0_PA4,
},
#endif
-#if defined (CONFIG_SENSORS_AK8975)
+#if defined (CONFIG_COMPASS_AK8975)
{
.type = "ak8975",
- .addr = 0x1c,
+ .addr = 0x0d,
.flags = 0,
- .irq = RK29_PIN4_PA1,
+ .irq = RK29_PIN0_PA4,
},
#endif
-#if defined (CONFIG_ANX7150)
+};
+#endif
+
+#ifdef CONFIG_I2C1_RK29
+static struct i2c_board_info __initdata board_i2c1_devices[] = {
+#if defined (CONFIG_RK1000_CONTROL1)
{
- .type = "anx7150",
- .addr = 0x39, //0x39, 0x3d
+ .type = "rk1000_control",
+ .addr = 0x40,
.flags = 0,
- .irq = RK29_PIN1_PD7,
},
#endif
+#if defined (CONFIG_ANX7150)
+ {
+ .type = "anx7150",
+ .addr = 0x39, //0x39, 0x3d
+ .flags = 0,
+ .irq = RK29_PIN1_PD7,
+ },
+#endif
};
#endif
.platform_data = &p1003_info,
},
#endif
+#if defined (CONFIG_EETI_EGALAX)
+ {
+ .type = "egalax_i2c",
+ .addr = 0x04,
+ .flags = 0,
+ .irq = RK29_PIN0_PA2,
+ .platform_data = &eeti_egalax_info,
+ },
+#endif
};
#endif
#define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
#define SENSOR_IIC_ADDR_0 0x78
#define SENSOR_IIC_ADAPTER_ID_0 1
-#define SENSOR_POWER_PIN_0 RK29_PIN6_PB7
+#define SENSOR_POWER_PIN_0 INVALID_GPIO
#define SENSOR_RESET_PIN_0 INVALID_GPIO
+#define SENSOR_POWERDN_PIN_0 RK29_PIN6_PB7
+#define SENSOR_FALSH_PIN_0 INVALID_GPIO
#define SENSOR_POWERACTIVE_LEVEL_0 RK29_CAM_POWERACTIVE_L
#define SENSOR_RESETACTIVE_LEVEL_0 RK29_CAM_RESETACTIVE_L
-
+#define SENSOR_POWERDNACTIVE_LEVEL_0 RK29_CAM_POWERDNACTIVE_H
+#define SENSOR_FLASHACTIVE_LEVEL_0 RK29_CAM_FLASHACTIVE_L
#define SENSOR_NAME_1 RK29_CAM_SENSOR_NAME_OV2659 /* front camera sensor */
#define SENSOR_IIC_ADDR_1 0x60
#define SENSOR_IIC_ADAPTER_ID_1 1
-#define SENSOR_POWER_PIN_1 RK29_PIN5_PD7
+#define SENSOR_POWER_PIN_1 INVALID_GPIO
#define SENSOR_RESET_PIN_1 INVALID_GPIO
+#define SENSOR_POWERDN_PIN_1 RK29_PIN5_PD7
+#define SENSOR_FALSH_PIN_1 INVALID_GPIO
#define SENSOR_POWERACTIVE_LEVEL_1 RK29_CAM_POWERACTIVE_L
#define SENSOR_RESETACTIVE_LEVEL_1 RK29_CAM_RESETACTIVE_L
+#define SENSOR_POWERDNACTIVE_LEVEL_1 RK29_CAM_POWERDNACTIVE_H
+#define SENSOR_FLASHACTIVE_LEVEL_1 RK29_CAM_FLASHACTIVE_L
static int rk29_sensor_io_init(void);
-static int rk29_sensor_io_deinit(void);
+static int rk29_sensor_io_deinit(int sensor);
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd,int on);
-struct rk29camera_platform_data rk29_camera_platform_data = {
+static struct rk29camera_platform_data rk29_camera_platform_data = {
.io_init = rk29_sensor_io_init,
.io_deinit = rk29_sensor_io_deinit,
+ .sensor_ioctrl = rk29_sensor_ioctrl,
.gpio_res = {
{
.gpio_reset = SENSOR_RESET_PIN_0,
.gpio_power = SENSOR_POWER_PIN_0,
- .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0),
+ .gpio_powerdown = SENSOR_POWERDN_PIN_0,
+ .gpio_flash = SENSOR_FALSH_PIN_0,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_0|SENSOR_RESETACTIVE_LEVEL_0|SENSOR_POWERDNACTIVE_LEVEL_0|SENSOR_FLASHACTIVE_LEVEL_0),
+ .gpio_init = 0,
.dev_name = SENSOR_NAME_0,
}, {
.gpio_reset = SENSOR_RESET_PIN_1,
.gpio_power = SENSOR_POWER_PIN_1,
- .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1),
+ .gpio_powerdown = SENSOR_POWERDN_PIN_1,
+ .gpio_flash = SENSOR_FALSH_PIN_1,
+ .gpio_flag = (SENSOR_POWERACTIVE_LEVEL_1|SENSOR_RESETACTIVE_LEVEL_1|SENSOR_POWERDNACTIVE_LEVEL_1|SENSOR_FLASHACTIVE_LEVEL_1),
+ .gpio_init = 0,
.dev_name = SENSOR_NAME_1,
}
},
{
int ret = 0, i;
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+ unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
unsigned int camera_ioflag;
for (i=0; i<2; i++) {
camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
+ camera_powerdown = rk29_camera_platform_data.gpio_res[i].gpio_powerdown;
+ camera_flash = rk29_camera_platform_data.gpio_res[i].gpio_flash;
camera_ioflag = rk29_camera_platform_data.gpio_res[i].gpio_flag;
+ rk29_camera_platform_data.gpio_res[i].gpio_init = 0;
if (camera_power != INVALID_GPIO) {
ret = gpio_request(camera_power, "camera power");
if (ret)
- continue;
-
+ goto sensor_io_int_loop_end;
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERACTIVE_MASK;
gpio_set_value(camera_reset, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
gpio_direction_output(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s....power pin(%d) init success(0x%x) \n",__FUNCTION__,camera_power,(((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
}
if (camera_reset != INVALID_GPIO) {
ret = gpio_request(camera_reset, "camera reset");
- if (ret) {
- if (camera_power != INVALID_GPIO)
- gpio_free(camera_power);
-
- continue;
- }
-
+ if (ret)
+ goto sensor_io_int_loop_end;
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_RESETACTIVE_MASK;
gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
gpio_direction_output(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s....%d %x \n",__FUNCTION__,__LINE__,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s....reset pin(%d) init success(0x%x)\n",__FUNCTION__,camera_reset,((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
}
- }
- return 0;
-}
+ if (camera_powerdown != INVALID_GPIO) {
+ ret = gpio_request(camera_powerdown, "camera powerdown");
+ if (ret)
+ goto sensor_io_int_loop_end;
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_POWERDNACTIVE_MASK;
+ gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+ gpio_direction_output(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
-static int rk29_sensor_io_deinit(void)
-{
- unsigned int i;
- unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+ //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
- //printk("\n%s....%d ******** ddl *********\n",__FUNCTION__,__LINE__);
+ }
- for (i=0; i<2; i++) {
- camera_reset = rk29_camera_platform_data.gpio_res[i].gpio_reset;
- camera_power = rk29_camera_platform_data.gpio_res[i].gpio_power;
+ if (camera_flash != INVALID_GPIO) {
+ ret = gpio_request(camera_flash, "camera flash");
+ if (ret)
+ goto sensor_io_int_loop_end;
+ rk29_camera_platform_data.gpio_res[i].gpio_init |= RK29_CAM_FLASHACTIVE_MASK;
+ gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+ gpio_direction_output(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
- if (camera_power != INVALID_GPIO){
- gpio_direction_input(camera_power);
- gpio_free(camera_power);
- }
+ //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
- if (camera_reset != INVALID_GPIO) {
- gpio_direction_input(camera_reset);
- gpio_free(camera_reset);
}
+ continue;
+sensor_io_int_loop_end:
+ rk29_sensor_io_deinit(i);
+ continue;
}
return 0;
}
-
-static int rk29_sensor_power(struct device *dev, int on)
+static int rk29_sensor_io_deinit(int sensor)
{
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
- unsigned int camera_ioflag;
+ unsigned int camera_powerdown = INVALID_GPIO, camera_flash = INVALID_GPIO;
+
+ camera_reset = rk29_camera_platform_data.gpio_res[sensor].gpio_reset;
+ camera_power = rk29_camera_platform_data.gpio_res[sensor].gpio_power;
+ camera_powerdown = rk29_camera_platform_data.gpio_res[sensor].gpio_powerdown;
+ camera_flash = rk29_camera_platform_data.gpio_res[sensor].gpio_flash;
+
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERACTIVE_MASK) {
+ if (camera_power != INVALID_GPIO) {
+ gpio_direction_input(camera_power);
+ gpio_free(camera_power);
+ }
+ }
+
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_RESETACTIVE_MASK) {
+ if (camera_reset != INVALID_GPIO) {
+ gpio_direction_input(camera_reset);
+ gpio_free(camera_reset);
+ }
+ }
+
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_POWERDNACTIVE_MASK) {
+ if (camera_powerdown != INVALID_GPIO) {
+ gpio_direction_input(camera_powerdown);
+ gpio_free(camera_powerdown);
+ }
+ }
+
+ if (rk29_camera_platform_data.gpio_res[sensor].gpio_init & RK29_CAM_FLASHACTIVE_MASK) {
+ if (camera_flash != INVALID_GPIO) {
+ gpio_direction_input(camera_flash);
+ gpio_free(camera_flash);
+ }
+ }
+
+ rk29_camera_platform_data.gpio_res[sensor].gpio_init = 0;
+ return 0;
+}
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
+{
+ unsigned int camera_power=INVALID_GPIO,camera_reset=INVALID_GPIO, camera_powerdown=INVALID_GPIO,camera_flash = INVALID_GPIO;
+ unsigned int camera_ioflag,camera_io_init;
+ int ret = RK29_CAM_IO_SUCCESS;
if(rk29_camera_platform_data.gpio_res[0].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[0].dev_name, dev_name(dev)) == 0)) {
- camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
- camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
+ camera_power = rk29_camera_platform_data.gpio_res[0].gpio_power;
+ camera_reset = rk29_camera_platform_data.gpio_res[0].gpio_reset;
+ camera_powerdown = rk29_camera_platform_data.gpio_res[0].gpio_powerdown;
+ camera_flash = rk29_camera_platform_data.gpio_res[0].gpio_flash;
camera_ioflag = rk29_camera_platform_data.gpio_res[0].gpio_flag;
+ camera_io_init = rk29_camera_platform_data.gpio_res[0].gpio_init;
} else if (rk29_camera_platform_data.gpio_res[1].dev_name && (strcmp(rk29_camera_platform_data.gpio_res[1].dev_name, dev_name(dev)) == 0)) {
+ camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
camera_reset = rk29_camera_platform_data.gpio_res[1].gpio_reset;
- camera_power = rk29_camera_platform_data.gpio_res[1].gpio_power;
+ camera_powerdown = rk29_camera_platform_data.gpio_res[1].gpio_powerdown;
+ camera_flash = rk29_camera_platform_data.gpio_res[1].gpio_flash;
camera_ioflag = rk29_camera_platform_data.gpio_res[1].gpio_flag;
+ camera_io_init = rk29_camera_platform_data.gpio_res[1].gpio_init;
}
- if (camera_reset != INVALID_GPIO) {
- gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
- }
- if (camera_power != INVALID_GPIO) {
- if (on) {
- gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
- } else {
- gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
- //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ switch (cmd)
+ {
+ case Cam_Power:
+ {
+ if (camera_power != INVALID_GPIO) {
+ if (camera_io_init & RK29_CAM_POWERACTIVE_MASK) {
+ if (on) {
+ gpio_set_value(camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, ((camera_ioflag&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ msleep(10);
+ } else {
+ gpio_set_value(camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_power, (((~camera_ioflag)&RK29_CAM_POWERACTIVE_MASK)>>RK29_CAM_POWERACTIVE_BITPOS));
+ }
+ } else {
+ ret = RK29_CAM_EIO_REQUESTFAIL;
+ printk("\n%s..%s..PowerPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
+ }
+ } else {
+ ret = RK29_CAM_EIO_INVALID;
+ }
+ break;
+ }
+ case Cam_Reset:
+ {
+ if (camera_reset != INVALID_GPIO) {
+ if (camera_io_init & RK29_CAM_RESETACTIVE_MASK) {
+ if (on) {
+ gpio_set_value(camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_reset, ((camera_ioflag&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ } else {
+ gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ }
+ } else {
+ ret = RK29_CAM_EIO_REQUESTFAIL;
+ printk("\n%s..%s..ResetPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_reset);
+ }
+ } else {
+ ret = RK29_CAM_EIO_INVALID;
+ }
+ break;
}
- }
- if (camera_reset != INVALID_GPIO) {
- if (on) {
- msleep(3); /* delay 3 ms */
- gpio_set_value(camera_reset,(((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
- //printk("\n%s..%s..ResetPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_reset, (((~camera_ioflag)&RK29_CAM_RESETACTIVE_MASK)>>RK29_CAM_RESETACTIVE_BITPOS));
+ case Cam_PowerDown:
+ {
+ if (camera_powerdown != INVALID_GPIO) {
+ if (camera_io_init & RK29_CAM_POWERDNACTIVE_MASK) {
+ if (on) {
+ gpio_set_value(camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerDownPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_powerdown, ((camera_ioflag&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+ } else {
+ gpio_set_value(camera_powerdown,(((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+ //printk("\n%s..%s..PowerDownPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_powerdown, (((~camera_ioflag)&RK29_CAM_POWERDNACTIVE_MASK)>>RK29_CAM_POWERDNACTIVE_BITPOS));
+ }
+ } else {
+ ret = RK29_CAM_EIO_REQUESTFAIL;
+ printk("\n%s..%s..PowerDownPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_powerdown);
+ }
+ } else {
+ ret = RK29_CAM_EIO_INVALID;
+ }
+ break;
}
- }
+
+ case Cam_Flash:
+ {
+ if (camera_flash != INVALID_GPIO) {
+ if (camera_io_init & RK29_CAM_FLASHACTIVE_MASK) {
+ if (on) {
+ gpio_set_value(camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+ //printk("\n%s..%s..FlashPin=%d ..PinLevel = %x \n",__FUNCTION__,dev_name(dev),camera_flash, ((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+ } else {
+ gpio_set_value(camera_flash,(((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+ //printk("\n%s..%s..FlashPin= %d..PinLevel = %x \n",__FUNCTION__,dev_name(dev), camera_flash, (((~camera_ioflag)&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+ }
+ } else {
+ ret = RK29_CAM_EIO_REQUESTFAIL;
+ printk("\n%s..%s..FlashPin=%d request failed!\n",__FUNCTION__,dev_name(dev),camera_flash);
+ }
+ } else {
+ ret = RK29_CAM_EIO_INVALID;
+ }
+ break;
+ }
+
+ default:
+ {
+ printk("%s cmd(0x%x) is unknown!\n",__FUNCTION__, cmd);
+ break;
+ }
+ }
+ return ret;
+}
+static int rk29_sensor_power(struct device *dev, int on)
+{
+ rk29_sensor_ioctrl(dev,Cam_Power,on);
return 0;
}
+static int rk29_sensor_reset(struct device *dev)
+{
+ rk29_sensor_ioctrl(dev,Cam_Reset,1);
+ msleep(2);
+ rk29_sensor_ioctrl(dev,Cam_Reset,0);
+ return 0;
+}
+static int rk29_sensor_powerdown(struct device *dev, int on)
+{
+ return rk29_sensor_ioctrl(dev,Cam_PowerDown,on);
+}
#if (SENSOR_IIC_ADDR_0 != 0x00)
static struct i2c_board_info rk29_i2c_cam_info_0[] = {
{
},
};
-struct soc_camera_link rk29_iclink_0 = {
+static struct soc_camera_link rk29_iclink_0 = {
.bus_id = RK29_CAM_PLATFORM_DEV_ID,
.power = rk29_sensor_power,
+ .powerdown = rk29_sensor_powerdown,
.board_info = &rk29_i2c_cam_info_0[0],
.i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_0,
.module_name = SENSOR_NAME_0,
};
/*platform_device : soc-camera need */
-struct platform_device rk29_soc_camera_pdrv_0 = {
+static struct platform_device rk29_soc_camera_pdrv_0 = {
.name = "soc-camera-pdrv",
.id = 0,
.dev = {
},
};
-struct soc_camera_link rk29_iclink_1 = {
+static struct soc_camera_link rk29_iclink_1 = {
.bus_id = RK29_CAM_PLATFORM_DEV_ID,
.power = rk29_sensor_power,
+ .powerdown = rk29_sensor_powerdown,
.board_info = &rk29_i2c_cam_info_1[0],
.i2c_adapter_id = SENSOR_IIC_ADAPTER_ID_1,
.module_name = SENSOR_NAME_1,
};
/*platform_device : soc-camera need */
-struct platform_device rk29_soc_camera_pdrv_1 = {
+static struct platform_device rk29_soc_camera_pdrv_1 = {
.name = "soc-camera-pdrv",
.id = 1,
.dev = {
static u64 rockchip_device_camera_dmamask = 0xffffffffUL;
-struct resource rk29_camera_resource[] = {
+static struct resource rk29_camera_resource[] = {
[0] = {
.start = RK29_VIP_PHYS,
.end = RK29_VIP_PHYS + RK29_VIP_SIZE - 1,
};
/*platform_device : */
-struct platform_device rk29_device_camera = {
+static struct platform_device rk29_device_camera = {
.name = RK29_CAM_DRV_NAME,
.id = RK29_CAM_PLATFORM_DEV_ID, /* This is used to put cameras on this interface */
.num_resources = ARRAY_SIZE(rk29_camera_resource),
#define PWM_MUX_NAME GPIO1B5_PWM0_NAME
#define PWM_MUX_MODE GPIO1L_PWM0
#define PWM_MUX_MODE_GPIO GPIO1L_GPIO1B5
+#define PWM_GPIO RK29_PIN1_PB5
#define PWM_EFFECT_VALUE 1
//#define LCD_DISP_ON_PIN
rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
return ret;
}
+
+static int rk29_backlight_pwm_suspend(void)
+{
+ int ret = 0;
+ rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE_GPIO);
+ if (ret = gpio_request(PWM_GPIO, NULL)) {
+ printk("func %s, line %d: request gpio fail\n", __FUNCTION__, __LINE__);
+ return -1;
+ }
+ gpio_direction_output(PWM_GPIO, GPIO_LOW);
+ return ret;
+}
+
+static int rk29_backlight_pwm_resume(void)
+{
+ gpio_free(PWM_GPIO);
+ rk29_mux_api_set(PWM_MUX_NAME, PWM_MUX_MODE);
+ return 0;
+}
+
struct rk29_bl_info rk29_bl_info = {
.pwm_id = PWM_ID,
.bl_ref = PWM_EFFECT_VALUE,
.io_init = rk29_backlight_io_init,
.io_deinit = rk29_backlight_io_deinit,
+ .pwm_suspend = rk29_backlight_pwm_suspend,
+ .pwm_resume = rk29_backlight_pwm_resume,
};
#endif
+/*****************************************************************************************
+* pwm voltage regulator devices
+******************************************************************************************/
+#if defined (CONFIG_RK29_PWM_REGULATOR)
+
+#define REGULATOR_PWM_ID 2
+#define REGULATOR_PWM_MUX_NAME GPIO2A3_SDMMC0WRITEPRT_PWM2_NAME
+#define REGULATOR_PWM_MUX_MODE GPIO2L_PWM2
+#define REGULATOR_PWM_MUX_MODE_GPIO GPIO2L_GPIO2A3
+#define REGULATOR_PWM_GPIO RK29_PIN2_PA3
+
+static struct regulator_consumer_supply pwm_consumers[] = {
+ {
+ .supply = "vcore",
+ }
+};
+
+static struct regulator_init_data rk29_pwm_regulator_data = {
+ .constraints = {
+ .name = "PWM2",
+ .min_uV = 950000,
+ .max_uV = 1400000,
+ .apply_uV = 1,
+ .valid_ops_mask = REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE,
+ },
+ .num_consumer_supplies = ARRAY_SIZE(pwm_consumers),
+ .consumer_supplies = pwm_consumers,
+};
+
+static struct pwm_platform_data rk29_regulator_pwm_platform_data = {
+ .pwm_id = REGULATOR_PWM_ID,
+ .pwm_gpio = REGULATOR_PWM_GPIO,
+ //.pwm_iomux_name[] = REGULATOR_PWM_MUX_NAME;
+ .pwm_iomux_name = REGULATOR_PWM_MUX_NAME,
+ .pwm_iomux_pwm = REGULATOR_PWM_MUX_MODE,
+ .pwm_iomux_gpio = REGULATOR_PWM_MUX_MODE_GPIO,
+ .init_data = &rk29_pwm_regulator_data,
+};
+
+static struct platform_device rk29_device_pwm_regulator = {
+ .name = "pwm-voltage-regulator",
+ .id = -1,
+ .dev = {
+ .platform_data = &rk29_regulator_pwm_platform_data,
+ },
+};
+
+#endif
+
/*****************************************************************************************
* SDMMC devices
*****************************************************************************************/
rk29_mux_api_set(GPIO1D3_SDMMC0DATA1_NAME, GPIO1H_SDMMC0_DATA1);
rk29_mux_api_set(GPIO1D4_SDMMC0DATA2_NAME, GPIO1H_SDMMC0_DATA2);
rk29_mux_api_set(GPIO1D5_SDMMC0DATA3_NAME, GPIO1H_SDMMC0_DATA3);
- rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
+ rk29_mux_api_set(GPIO2A2_SDMMC0DETECTN_NAME, GPIO2L_SDMMC0_DETECT_N);
rk29_mux_api_set(GPIO5D5_SDMMC0PWREN_NAME, GPIO5H_GPIO5D5); ///GPIO5H_SDMMC0_PWR_EN); ///GPIO5H_GPIO5D5);
gpio_request(RK29_PIN5_PD5,"sdmmc");
+#if 0
gpio_set_value(RK29_PIN5_PD5,GPIO_HIGH);
mdelay(100);
gpio_set_value(RK29_PIN5_PD5,GPIO_LOW);
+#else
+ gpio_direction_output(RK29_PIN5_PD5,GPIO_LOW);
+#endif
return 0;
}
return 0;
}
-#ifdef CONFIG_WIFI_CONTROL_FUNC
+#ifdef CONFIG_WIFI_CONTROL_FUNC
static int rk29sdk_wifi_status(struct device *dev);
static int rk29sdk_wifi_status_register(void (*callback)(int card_presend, void *dev_id), void *dev_id);
#endif
{
if (gpio_request(RK29SDK_WIFI_BT_GPIO_POWER_N, "wifi_bt_power")) {
pr_info("%s: request wifi_bt power gpio failed\n", __func__);
- return -1;
+ return -1;
}
-
+
if (gpio_request(RK29SDK_WIFI_GPIO_RESET_N, "wifi reset")) {
pr_info("%s: request wifi reset gpio failed\n", __func__);
gpio_free(RK29SDK_WIFI_BT_GPIO_POWER_N);
return -1;
}
-
+
if (gpio_request(RK29SDK_BT_GPIO_RESET_N, "bt reset")) {
pr_info("%s: request bt reset gpio failed\n", __func__);
gpio_free(RK29SDK_WIFI_GPIO_RESET_N);
return -1;
}
-
+
gpio_direction_output(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
gpio_direction_output(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
- gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
-
+ gpio_direction_output(RK29SDK_BT_GPIO_RESET_N, GPIO_LOW);
+
pr_info("%s: init finished\n",__func__);
-
+
return 0;
}
{
pr_info("%s: %d\n", __func__, on);
if (on){
- gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
+ gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_HIGH);
+ gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_HIGH);
mdelay(100);
pr_info("wifi turn on power\n");
}else{
if (!rk29sdk_bt_power_state){
- gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, on);
+ gpio_set_value(RK29SDK_WIFI_BT_GPIO_POWER_N, GPIO_LOW);
mdelay(100);
pr_info("wifi shut off power\n");
}else
{
pr_info("wifi shouldn't shut off power, bt is using it!\n");
}
+ gpio_set_value(RK29SDK_WIFI_GPIO_RESET_N, GPIO_LOW);
}
return 0;
}
-static int rk29sdk_wifi_set_carddetect(int val)
+int rk29sdk_wifi_set_carddetect(int val)
{
pr_info("%s:%d\n", __func__, val);
rk29sdk_wifi_cd = val;
}
return 0;
}
+EXPORT_SYMBOL(rk29sdk_wifi_set_carddetect);
+
+static struct wifi_mem_prealloc wifi_mem_array[PREALLOC_WLAN_SEC_NUM] = {
+ {NULL, (WLAN_SECTION_SIZE_0 + PREALLOC_WLAN_SECTION_HEADER)},
+ {NULL, (WLAN_SECTION_SIZE_1 + PREALLOC_WLAN_SECTION_HEADER)},
+ {NULL, (WLAN_SECTION_SIZE_2 + PREALLOC_WLAN_SECTION_HEADER)},
+ {NULL, (WLAN_SECTION_SIZE_3 + PREALLOC_WLAN_SECTION_HEADER)}
+};
+
+static void *rk29sdk_mem_prealloc(int section, unsigned long size)
+{
+ if (section == PREALLOC_WLAN_SEC_NUM)
+ return wlan_static_skb;
+
+ if ((section < 0) || (section > PREALLOC_WLAN_SEC_NUM))
+ return NULL;
+
+ if (wifi_mem_array[section].size < size)
+ return NULL;
+
+ return wifi_mem_array[section].mem_ptr;
+}
+
+int __init rk29sdk_init_wifi_mem(void)
+{
+ int i;
+ int j;
+
+ for (i = 0 ; i < WLAN_SKB_BUF_NUM ; i++) {
+ wlan_static_skb[i] = dev_alloc_skb(
+ ((i < (WLAN_SKB_BUF_NUM / 2)) ? 4096 : 8192));
+
+ if (!wlan_static_skb[i])
+ goto err_skb_alloc;
+ }
+
+ for (i = 0 ; i < PREALLOC_WLAN_SEC_NUM ; i++) {
+ wifi_mem_array[i].mem_ptr =
+ kmalloc(wifi_mem_array[i].size, GFP_KERNEL);
+
+ if (!wifi_mem_array[i].mem_ptr)
+ goto err_mem_alloc;
+ }
+ return 0;
+
+err_mem_alloc:
+ pr_err("Failed to mem_alloc for WLAN\n");
+ for (j = 0 ; j < i ; j++)
+ kfree(wifi_mem_array[j].mem_ptr);
+
+ i = WLAN_SKB_BUF_NUM;
+
+err_skb_alloc:
+ pr_err("Failed to skb_alloc for WLAN\n");
+ for (j = 0 ; j < i ; j++)
+ dev_kfree_skb(wlan_static_skb[j]);
+
+ return -ENOMEM;
+}
static struct wifi_platform_data rk29sdk_wifi_control = {
.set_power = rk29sdk_wifi_power,
.set_reset = rk29sdk_wifi_reset,
.set_carddetect = rk29sdk_wifi_set_carddetect,
+ .mem_prealloc = rk29sdk_mem_prealloc,
};
static struct platform_device rk29sdk_wifi_device = {
.name = "bcm4329_wlan",
};
#endif
+
+/* bluetooth rfkill device */
+static struct platform_device rk29sdk_rfkill = {
+ .name = "rk29sdk_rfkill",
+ .id = -1,
+};
+
+
#ifdef CONFIG_VIVANTE
static struct resource resources_gpu[] = {
[0] = {
[1] = {
.name = "gpu_base",
.start = RK29_GPU_PHYS,
- .end = RK29_GPU_PHYS + RK29_GPU_PHYS_SIZE,
+ .end = RK29_GPU_PHYS + RK29_GPU_SIZE,
.flags = IORESOURCE_MEM,
},
[2] = {
.flags = IORESOURCE_MEM,
},
};
-struct platform_device rk29_device_gpu = {
+static struct platform_device rk29_device_gpu = {
.name = "galcore",
.id = 0,
.num_resources = ARRAY_SIZE(resources_gpu),
rk29_mux_api_set(GPIO0A7_MIIMDCLK_NAME, GPIO0L_MII_MDCLK);
rk29_mux_api_set(GPIO0A6_MIIMD_NAME, GPIO0L_MII_MD);
#endif
+ #ifdef CONFIG_RK29_PWM_REGULATOR
+ rk29_mux_api_set(REGULATOR_PWM_MUX_NAME,REGULATOR_PWM_MUX_MODE);
+ #endif
}
static struct platform_device *devices[] __initdata = {
#ifdef CONFIG_UART1_RK29
&rk29_device_uart1,
#endif
+#ifdef CONFIG_UART0_RK29
+ &rk29_device_uart0,
+#endif
+#ifdef CONFIG_UART2_RK29
+ &rk29_device_uart2,
+#endif
+
+#ifdef CONFIG_RK29_PWM_REGULATOR
+ &rk29_device_pwm_regulator,
+#endif
#ifdef CONFIG_SPIM0_RK29
&rk29xx_device_spi0m,
#endif
#ifdef CONFIG_WIFI_CONTROL_FUNC
&rk29sdk_wifi_device,
#endif
+
+#ifdef CONFIG_BT
+ &rk29sdk_rfkill,
+#endif
+
#ifdef CONFIG_MTD_NAND_RK29
&rk29_device_nand,
#endif
#ifdef CONFIG_FB_RK29
&rk29_device_fb,
+ &rk29_device_dma_cpy,
#endif
#ifdef CONFIG_BACKLIGHT_RK29_BL
&rk29_device_backlight,
#ifdef CONFIG_RK29_IPP
&rk29_device_ipp,
#endif
+#ifdef CONFIG_VIDEO_RK29XX_VOUT
+ &rk29_v4l2_output_devce,
+#endif
};
/*****************************************************************************************
*****************************************************************************************/
static int rk29_vmac_register_set(void)
{
- //config rk29 vmac as rmii, 100MHz
+ //config rk29 vmac as rmii, 100MHz
u32 value= readl(RK29_GRF_BASE + 0xbc);
value = (value & 0xfff7ff) | (0x400);
writel(value, RK29_GRF_BASE + 0xbc);
{
int err;
- //set dm9161 rmii
- rk29_mux_api_set(GPIO2D3_I2S0SDI_MIICOL_NAME, GPIO2H_GPIO2D3);
- err = gpio_request(RK29_PIN2_PD3, "rmii");
- if (err) {
- gpio_free(RK29_PIN2_PD3);
- printk("-------request RK29_PIN2_PD3 fail--------\n");
- return -1;
- }
- gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
- gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
-
- //rmii power on
- err = gpio_request(RK29_PIN6_PB0, "rmii_power_en");
+ //phy power gpio
+ err = gpio_request(RK29_PIN6_PB0, "phy_power_en");
if (err) {
gpio_free(RK29_PIN6_PB0);
- gpio_free(RK29_PIN2_PD3);
printk("-------request RK29_PIN6_PB0 fail--------\n");
return -1;
- }
- gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
- gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
-
+ }
+ //phy power down
+ gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
+ gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
+
+ return 0;
+}
+
+static int rk29_rmii_io_deinit(void)
+{
+ //phy power down
+ gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
+ gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
+ //free
+ gpio_free(RK29_PIN6_PB0);
return 0;
}
static int rk29_rmii_power_control(int enable)
{
if (enable) {
- //set dm9161 as rmii
- gpio_direction_output(RK29_PIN2_PD3, GPIO_HIGH);
- gpio_set_value(RK29_PIN2_PD3, GPIO_HIGH);
-
- //enable rmii power
+ //enable phy power
gpio_direction_output(RK29_PIN6_PB0, GPIO_HIGH);
gpio_set_value(RK29_PIN6_PB0, GPIO_HIGH);
-
}
else {
gpio_direction_output(RK29_PIN6_PB0, GPIO_LOW);
gpio_set_value(RK29_PIN6_PB0, GPIO_LOW);
}
-
return 0;
}
struct rk29_vmac_platform_data rk29_vmac_pdata = {
.vmac_register_set = rk29_vmac_register_set,
.rmii_io_init = rk29_rmii_io_init,
+ .rmii_io_deinit = rk29_rmii_io_deinit,
.rmii_power_control = rk29_rmii_power_control,
};
* author: cmc@rock-chips.com
*****************************************************************************************/
#define SPI_CHIPSELECT_NUM 2
-struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
+static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = {
{
.name = "spi0 cs0",
.cs_gpio = RK29_PIN2_PC1,
- .cs_iomux_name = NULL,
+ .cs_iomux_name = GPIO2C1_SPI0CSN0_NAME,
+ .cs_iomux_mode = GPIO2H_SPI0_CSN0,
},
{
.name = "spi0 cs1",
}
};
-struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
+static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = {
{
.name = "spi1 cs0",
.cs_gpio = RK29_PIN2_PC5,
- .cs_iomux_name = NULL,
+ .cs_iomux_name = GPIO2C5_SPI1CSN0_NAME,
+ .cs_iomux_mode = GPIO2H_SPI1_CSN0,
},
{
.name = "spi1 cs1",
static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
{
#if 1
- int i,j,ret;
-
- //cs
+ int i;
if (cs_gpios) {
for (i=0; i<cs_num; i++) {
rk29_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
- ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
- if (ret) {
- for (j=0;j<i;j++) {
- gpio_free(cs_gpios[j].cs_gpio);
- //rk29_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
- }
- printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
- return -1;
- }
- gpio_direction_output(cs_gpios[i].cs_gpio, GPIO_HIGH);
}
}
#endif
static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
{
-#if 1
- int i;
-
- if (cs_gpios) {
- for (i=0; i<cs_num; i++) {
- gpio_free(cs_gpios[i].cs_gpio);
- //rk29_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
- }
- }
-#endif
return 0;
}
static void __init machine_rk29_init_irq(void)
{
rk29_gic_init_irq();
- rk29_gpio_init(rk29_gpiobankinit, MAX_BANK);
- rk29_gpio_irq_setup();
+ rk29_gpio_init();
}
+
#define POWER_ON_PIN RK29_PIN4_PA4
+static void rk29_pm_power_off(void)
+{
+ printk(KERN_ERR "rk29_pm_power_off start...\n");
+ gpio_direction_output(POWER_ON_PIN, GPIO_LOW);
+ while (1);
+}
+
static void __init machine_rk29_board_init(void)
{
rk29_board_iomux_init();
- gpio_request(POWER_ON_PIN,"poweronpin");
+
+ gpio_request(POWER_ON_PIN,"poweronpin");
gpio_set_value(POWER_ON_PIN, GPIO_HIGH);
gpio_direction_output(POWER_ON_PIN, GPIO_HIGH);
-
-#ifdef CONFIG_WIFI_CONTROL_FUNC
- rk29sdk_wifi_bt_gpio_control_init();
-#endif
+ pm_power_off = rk29_pm_power_off;
platform_add_devices(devices, ARRAY_SIZE(devices));
#ifdef CONFIG_I2C0_RK29
#endif
spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices));
+
+#ifdef CONFIG_WIFI_CONTROL_FUNC
+ rk29sdk_wifi_bt_gpio_control_init();
+ rk29sdk_init_wifi_mem();
+#endif
}
static void __init machine_rk29_fixup(struct machine_desc *desc, struct tag *tags,
static void __init machine_rk29_mapio(void)
{
rk29_map_common_io();
+ rk29_setup_early_printk();
+ rk29_sram_init();
rk29_clock_init();
rk29_iomux_init();
}