#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>
.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
[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 = &mma8452_info,
},
#endif
-#if defined (CONFIG_SENSORS_AK8973)
+#if defined (CONFIG_COMPASS_AK8973)
{
.type = "ak8973",
.addr = 0x1d,
.irq = RK29_PIN4_PA1,
},
#endif
-#if defined (CONFIG_SENSORS_AK8975)
+#if defined (CONFIG_COMPASS_AK8975)
{
.type = "ak8975",
.addr = 0x1d,
#define SENSOR_NAME_0 RK29_CAM_SENSOR_NAME_OV5642 /* back camera sensor */
#define SENSOR_IIC_ADDR_0 0x00
#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 INVALID_GPIO
+#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_OV2655 /* 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 = {
.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));
+
+ }
+
+ 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));
+
+ //printk("\n%s....powerdown pin(%d) init success(0x%x) \n",__FUNCTION__,camera_powerdown,((camera_ioflag&RK29_CAM_POWERDNACTIVE_BITPOS)>>RK29_CAM_POWERDNACTIVE_BITPOS));
}
+
+ 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));
+
+ //printk("\n%s....flash pin(%d) init success(0x%x) \n",__FUNCTION__,camera_flash,((camera_ioflag&RK29_CAM_FLASHACTIVE_MASK)>>RK29_CAM_FLASHACTIVE_BITPOS));
+
+ }
+ continue;
+sensor_io_int_loop_end:
+ rk29_sensor_io_deinit(i);
+ continue;
}
return 0;
}
-static int rk29_sensor_io_deinit(void)
+static int rk29_sensor_io_deinit(int sensor)
{
unsigned int i;
unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
+ 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);
+ }
+ }
- //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 (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 (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_POWERDNACTIVE_MASK) {
+ if (camera_powerdown != INVALID_GPIO) {
+ gpio_direction_input(camera_powerdown);
+ gpio_free(camera_powerdown);
+ }
+ }
- 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_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_power(struct device *dev, int on)
+static int rk29_sensor_ioctrl(struct device *dev,enum rk29camera_ioctrl_cmd cmd, int on)
{
- unsigned int camera_reset = INVALID_GPIO, camera_power = INVALID_GPIO;
- unsigned int camera_ioflag;
+ 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..ResetPin=%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 = {
.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,
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,
}
};
#endif
+
/*****************************************************************************************
* backlight devices
* author: nzy@rock-chips.com
.io_deinit = rk29_backlight_io_deinit,
};
#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_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
*****************************************************************************************/
[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] = {
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_RK29_PWM_REGULATOR
+ &rk29_device_pwm_regulator,
+#endif
#ifdef CONFIG_SPIM0_RK29
&rk29xx_device_spi0m,
#endif
* 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 __init machine_rk29_board_init(void)
static void __init machine_rk29_mapio(void)
{
rk29_map_common_io();
+ rk29_setup_early_printk();
+ rk29_sram_init();
rk29_clock_init();
rk29_iomux_init();
}