static int switch_mclk_gpio_mfp(int pinid) { unsigned int val; unsigned long mclk_mfps[] = { GPIO077_CAM_MCLK | MFP_LPM_DRIVE_LOW, }; unsigned long gpio_mfps[] = { GPIO077_GPIO_77 }; switch_mclk_gpio = mfp_to_gpio(GPIO077_GPIO_77); if (pinid == MCLK_PIN) { mfp_config(ARRAY_AND_SIZE(mclk_mfps)); val = mfp_read(switch_mclk_gpio); printk("--------MCLK pin Switchs TO mclk, MFP Setting is :0x%x---------", val); } if (pinid == GPIO_PIN) { mfp_config(ARRAY_AND_SIZE(gpio_mfps)); val = mfp_read(switch_mclk_gpio); printk("--------MCLK pin Switchs TO gpio, MFP Setting is :0x%x---------", val); if (switch_mclk_gpio && gpio_request(switch_mclk_gpio, "switch_mclk_gpio77")) { printk(KERN_ERR "------switch_mclk_gpio_mfp-------Request GPIO failed," "gpio: %d\n", switch_mclk_gpio); switch_mclk_gpio = 0; return -1; } gpio_direction_output(switch_mclk_gpio, 0); gpio_free(switch_mclk_gpio); } return 0; }
static int switch_i2c_gpio_mfp(int pinid) { unsigned int val,val1; unsigned long i2c_mfps[] = { GPIO079_CAM_SCL | MFP_LPM_FLOAT, GPIO080_CAM_SDA | MFP_LPM_FLOAT, }; unsigned long gpio_mfps[] = { GPIO079_GPIO_79, GPIO080_GPIO_80, }; switch_i2c_gpioa = mfp_to_gpio(GPIO079_GPIO_79); switch_i2c_gpiob = mfp_to_gpio(GPIO080_GPIO_80); if (pinid == I2C_PIN) { mfp_config(ARRAY_AND_SIZE(i2c_mfps)); val = mfp_read(switch_i2c_gpioa); val1 = mfp_read(switch_i2c_gpiob); printk("--------Pins Switchs TO I2C, MFP Setting is GPIO079 :0x%x, GPIO080 :0x%x---------", val, val1); } if (pinid == GPIO_PIN) { mfp_config(ARRAY_AND_SIZE(gpio_mfps)); val = mfp_read(switch_i2c_gpioa); val1 = mfp_read(switch_i2c_gpiob); printk("--------Pins Switchs TO GPIO, MFP Setting is GPIO079 :0x%x, GPIO080 :0x%x---------", val, val1); if (switch_i2c_gpioa && gpio_request(switch_i2c_gpioa, "switch_mclk_gpio79")) { printk(KERN_ERR "------switch_i2c_gpio_mfp-------Request GPIO failed," "gpio: %d\n", switch_i2c_gpioa); switch_i2c_gpioa = 0; return -1; } if (switch_i2c_gpiob && gpio_request(switch_i2c_gpiob, "switch_mclk_gpio80")) { printk(KERN_ERR "------switch_i2c_gpio_mfp-------Request GPIO failed," "gpio: %d\n", switch_i2c_gpiob); switch_i2c_gpiob = 0; return -1; } gpio_direction_output(switch_i2c_gpioa, 0); gpio_direction_output(switch_i2c_gpiob, 0); gpio_free(switch_i2c_gpioa); gpio_free(switch_i2c_gpiob); } return 0; }
static int ak7343_write(struct i2c_client *client, unsigned long reg, unsigned long val) { int ret = 0; unsigned long mfp_pin[2]; unsigned long i2c0_mfps[] = { GPIO053_GPIO_53, /* SCL */ GPIO054_GPIO_54, /* SDA */ }; unsigned long scl, sda; scl = MFP_PIN_GPIO53; sda = MFP_PIN_GPIO54; i2c_lock_adapter(client->adapter); if (gpio_request(scl, "SCL")) { pr_err("Failed to request GPIO for SCL pin!\n"); ret = -1; goto out0; } if (gpio_request(sda, "SDA")) { pr_err("Failed to request GPIO for SDA pin!\n"); ret = -1; goto out1; }; mfp_pin[0] = mfp_read(MFP_PIN_GPIO53); mfp_pin[1] = mfp_read(MFP_PIN_GPIO54); mfp_config(i2c0_mfps, ARRAY_SIZE(i2c0_mfps)); i2c_start(scl, sda); if (i2c_sendbyte(scl, sda, (client->addr<<1) | 0) < 0) { ret = -1; goto out2; } if (i2c_sendbyte(scl, sda, (u8)reg) < 0) { ret = -1; goto out2; } if (i2c_sendbyte(scl, sda, (u8)val) < 0) { ret = -1; goto out2; } out2: i2c_stop(scl, sda); mfp_write(MFP_PIN_GPIO53, mfp_pin[0]); mfp_write(MFP_PIN_GPIO54, mfp_pin[1]); gpio_free(sda); out1: gpio_free(scl); out0: i2c_unlock_adapter(client->adapter); return ret; }
static int ak7343_subdev_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) { struct ak7343 *core = to_ak7343(sd); struct i2c_client *client = v4l2_get_subdevdata(&core->subdev); unsigned long mfp_pin[2]; unsigned long i2c0_mfps[] = { GPIO053_GPIO_53, GPIO054_GPIO_54, }; unsigned long scl, sda; if (core->openflag == 1) return -EBUSY; core->openflag = 1; scl = MFP_PIN_GPIO53; sda = MFP_PIN_GPIO54; i2c_lock_adapter(client->adapter); if (gpio_request(scl, "SCL")) pr_err("Failed to request GPIO for SCL pin!\n"); if (gpio_request(sda, "SDA")) pr_err("Failed to request GPIO for SDA pin!\n"); mfp_pin[0] = mfp_read(MFP_PIN_GPIO53); mfp_pin[1] = mfp_read(MFP_PIN_GPIO54); mfp_config(i2c0_mfps, ARRAY_SIZE(i2c0_mfps)); gpio_direction_output(sda, 0); gpio_direction_output(scl, 0); mdelay(100); vcm_power(core, 1); mdelay(10); gpio_direction_output(sda, 1); gpio_direction_output(scl, 1); mfp_write(MFP_PIN_GPIO53, mfp_pin[0]); mfp_write(MFP_PIN_GPIO54, mfp_pin[1]); gpio_free(sda); gpio_free(scl); i2c_unlock_adapter(client->adapter); mdelay(120); ak7343_write(client, 0x05, 0x7a); ak7343_write(client, 0x01, 0x01); mdelay(200); ak7343_write(client, 0x02, 0x01); mdelay(120); ak7343_write(client, 0x01, 0x00); return 0; }