mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
在spi驱动休眠和唤醒的函数中加了解决spi_cs0漏电的代码,更新触摸面板的驱动
This commit is contained in:
@@ -1311,11 +1311,25 @@ static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_fix_leakage_bug(void)
|
||||
{
|
||||
gpio_direction_output(RK2818_PIN_PB4,GPIO_LOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_resume_leakage_bug(void)
|
||||
{
|
||||
gpio_direction_output(RK2818_PIN_PB4,GPIO_HIGH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct rk2818_spi_platform_data rk2818_spi_platdata = {
|
||||
.num_chipselect = SPI_CHIPSELECT_NUM,//raho 大板需要支持3个片选 dxj
|
||||
.chipselect_gpios = rk2818_spi_cs_gpios,
|
||||
.io_init = spi_io_init,
|
||||
.io_deinit = spi_io_deinit,
|
||||
.io_fix_leakage_bug=spi_io_fix_leakage_bug,
|
||||
.io_resume_leakage_bug=spi_io_resume_leakage_bug,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1311,11 +1311,25 @@ static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_fix_leakage_bug(void)
|
||||
{
|
||||
gpio_direction_output(RK2818_PIN_PB4,GPIO_LOW);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_resume_leakage_bug(void)
|
||||
{
|
||||
gpio_direction_output(RK2818_PIN_PB4,GPIO_HIGH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct rk2818_spi_platform_data rk2818_spi_platdata = {
|
||||
.num_chipselect = SPI_CHIPSELECT_NUM,//raho 大板需要支持3个片选 dxj
|
||||
.chipselect_gpios = rk2818_spi_cs_gpios,
|
||||
.io_init = spi_io_init,
|
||||
.io_deinit = spi_io_deinit,
|
||||
.io_fix_leakage_bug=spi_io_fix_leakage_bug,
|
||||
.io_resume_leakage_bug=spi_io_resume_leakage_bug,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -210,6 +210,8 @@ struct spi_cs_gpio {
|
||||
struct rk2818_spi_platform_data {
|
||||
int (*io_init)(struct spi_cs_gpio*, int);
|
||||
int (*io_deinit)(struct spi_cs_gpio*, int);
|
||||
int (*io_fix_leakage_bug)(void);
|
||||
int (*io_resume_leakage_bug)(void);
|
||||
struct spi_cs_gpio *chipselect_gpios;
|
||||
u16 num_chipselect;
|
||||
};
|
||||
|
||||
@@ -198,7 +198,7 @@ return ;
|
||||
static irqreturn_t Ctp_it7250_touch_irq(int irq, void *dev_id)
|
||||
{
|
||||
struct Ctp_it7250_data *Ctp_it7250 = dev_id;
|
||||
|
||||
//printk("%s++++ %d \r\n",__FUNCTION__,__LINE__);
|
||||
//rk28printk("%s++++ %d \r\n",__FUNCTION__,__LINE__);
|
||||
disable_irq_nosync(irq);
|
||||
//rk28printk("%s++++ %d irq=%d\r\n",__FUNCTION__,__LINE__,irq);
|
||||
@@ -313,7 +313,6 @@ ret = gpio_direction_input(client->irq);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ================================================================================
|
||||
// Function Name --- GetFirmwareInformation
|
||||
// Description --- Get firmware information
|
||||
@@ -457,7 +456,7 @@ bool IdentifyCapSensor(struct i2c_client *client)
|
||||
ucWriteLength = 1;
|
||||
ucReadLength = 0x0A;
|
||||
pucData[0] = 0x00;
|
||||
rk28printk("%s\r\n",__FUNCTION__);
|
||||
rk28printk("%s\r\n",__FUNCTION__);
|
||||
// Query
|
||||
do
|
||||
{//printk("first wait 111\r\n");
|
||||
@@ -699,6 +698,7 @@ int CaptouchHWInitial(struct i2c_client *client)
|
||||
if (!IdentifyCapSensor(client))
|
||||
{
|
||||
rk28printk("%s IdentifyCapSensor error \r\n",__FUNCTION__);
|
||||
printk("%s IdentifyCapSensor error \r\n",__FUNCTION__);
|
||||
return false;
|
||||
//goto resetagin;
|
||||
}
|
||||
@@ -706,12 +706,14 @@ int CaptouchHWInitial(struct i2c_client *client)
|
||||
if (!GetFirmwareInformation (client))
|
||||
{
|
||||
rk28printk("%s GetFirmwareInformation error \r\n",__FUNCTION__);
|
||||
printk("%s GetFirmwareInformation error \r\n",__FUNCTION__);
|
||||
// goto resetagin;
|
||||
}
|
||||
|
||||
if (!Get2DResolutions(client, &wXResolution, &wYResolution, &ucStep))
|
||||
{
|
||||
rk28printk("%s Get2DResolutions error \r\n",__FUNCTION__);
|
||||
printk("%s Get2DResolutions error \r\n",__FUNCTION__);
|
||||
// goto resetagin;
|
||||
}
|
||||
|
||||
@@ -956,9 +958,7 @@ static void Ctp_it7250_delaywork_func(struct work_struct *work)
|
||||
static int Ctp_it7250_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct Ctp_it7250_data *Ctp_it7250;
|
||||
// u16 TempReg=0x0;
|
||||
// u16 val=0x0;
|
||||
|
||||
|
||||
Ctp_it7250_client = client;
|
||||
rk28printk("+++++++ %s+++++++\n", __FUNCTION__);
|
||||
Ctp_it7250 = kzalloc(sizeof(struct Ctp_it7250_data), GFP_KERNEL);
|
||||
@@ -971,41 +971,34 @@ static void Ctp_it7250_delaywork_func(struct work_struct *work)
|
||||
// INIT_WORK(&Ctp_it7250->irq_work, Ctp_it7250_irq_worker);
|
||||
INIT_DELAYED_WORK(&Ctp_it7250->delaywork, Ctp_it7250_delaywork_func);
|
||||
|
||||
|
||||
Ctp_it7250->client = client;
|
||||
i2c_set_clientdata(client, Ctp_it7250);
|
||||
|
||||
|
||||
if (!CaptouchHWInitial(client))
|
||||
goto err_free_mem;
|
||||
Ctp_it7250_init_irq(client);
|
||||
if (!CaptouchHWInitial(client))
|
||||
goto err_free_mem;
|
||||
Ctp_it7250_init_irq(client);
|
||||
ts_input_init(client);
|
||||
// CTS_configure_pin(client);
|
||||
|
||||
{
|
||||
#if 0
|
||||
lp8725_lilo_en(2,0);
|
||||
mdelay(100);
|
||||
lp8725_lilo_en(2,0);
|
||||
mdelay(100);
|
||||
|
||||
lp8725_lilo_en(2,1);
|
||||
mdelay(100);
|
||||
lp8725_set_lilo_vol(2,300);
|
||||
mdelay(5);
|
||||
lp8725_lilo_en(2,1);
|
||||
mdelay(100);
|
||||
lp8725_set_lilo_vol(2,300);
|
||||
mdelay(5);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//不是查询模式,不需要轮询
|
||||
//schedule_delayed_work(&Ctp_it7250->delaywork,msecs_to_jiffies(50));
|
||||
|
||||
|
||||
rk28printk("+++++++ %s+++++++\n", __FUNCTION__);
|
||||
return 0;
|
||||
err_free_mem:
|
||||
kfree(Ctp_it7250);
|
||||
return false;
|
||||
err_free_mem:
|
||||
kfree(Ctp_it7250);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -1022,37 +1015,11 @@ static int Ctp_it7250_remove(struct i2c_client *client)
|
||||
#ifdef CONFIG_PM
|
||||
static int Ctp_it7250_suspend(struct i2c_client *client, pm_message_t state)
|
||||
{//pr_emerg("\n irq1=%d \n",irq1);
|
||||
struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);
|
||||
struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);
|
||||
|
||||
//send command to make ctp into sleep mode
|
||||
#if 1
|
||||
u8 ucWriteLength;
|
||||
u8 pucData[128];
|
||||
u8 ucQuery;
|
||||
|
||||
ucWriteLength = 3;
|
||||
pucData[0] = 0x04;
|
||||
pucData[1] = 0x00;
|
||||
pucData[2] = 0x02;
|
||||
|
||||
// Query
|
||||
do
|
||||
{
|
||||
if(!ReadQueryBuffer(client, &ucQuery))
|
||||
{
|
||||
ucQuery = QUERY_BUSY;
|
||||
}
|
||||
}while(ucQuery & QUERY_BUSY);
|
||||
|
||||
// Write Command
|
||||
rk28printk("%s WriteCommandBuffer\r\n",__FUNCTION__);
|
||||
if(!WriteCommandBuffer(client, pucData, ucWriteLength))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
//send sleep command end
|
||||
rk28printk("%s\n",__func__);
|
||||
|
||||
CaptouchMode(client, 2);
|
||||
disable_irq(Ctp_it7250->irq);
|
||||
|
||||
return 0;
|
||||
@@ -1060,14 +1027,21 @@ struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdat
|
||||
|
||||
static int Ctp_it7250_resume(struct i2c_client *client)
|
||||
{
|
||||
struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);
|
||||
//read command to wakeup ctp
|
||||
#if 1
|
||||
u8 ucQuery;
|
||||
ReadQueryBuffer(client, &ucQuery);
|
||||
#endif
|
||||
//wakeup end
|
||||
struct Ctp_it7250_data *Ctp_it7250 = (struct Ctp_it7250_data *)i2c_get_clientdata(client);
|
||||
|
||||
u8 ucQuery;
|
||||
rk28printk("%s\n",__func__);
|
||||
|
||||
if(gpio_direction_output(client->irq,GPIO_LOW))
|
||||
printk("%s:set pin output error\n",__func__);
|
||||
msleep(20);
|
||||
ReadQueryBuffer(client, &ucQuery);
|
||||
if (gpio_direction_input(client->irq))
|
||||
printk("%s:failed to set CTS_configure_pin gpio input\n",__func__);
|
||||
gpio_pull_updown(client->irq,GPIOPullUp);
|
||||
msleep(20);
|
||||
enable_irq(Ctp_it7250->irq);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
@@ -1086,9 +1060,9 @@ static struct i2c_driver Ctp_it7250_driver = {
|
||||
},
|
||||
.id_table = Ctp_it7250_id,
|
||||
.probe = Ctp_it7250_probe,
|
||||
.remove = Ctp_it7250_remove,
|
||||
.suspend = Ctp_it7250_suspend,
|
||||
.resume = Ctp_it7250_resume,
|
||||
.remove = Ctp_it7250_remove,
|
||||
.suspend = Ctp_it7250_suspend,
|
||||
.resume = Ctp_it7250_resume,
|
||||
};
|
||||
|
||||
static int __init Ctp_it7250_init(void)
|
||||
@@ -1113,3 +1087,4 @@ module_exit(Ctp_it7250_exit);
|
||||
|
||||
MODULE_AUTHOR("Robert_mu<robert.mu@rahotech.com>");
|
||||
|
||||
|
||||
|
||||
@@ -1451,13 +1451,17 @@ static int rk2818_spim_suspend(struct platform_device *pdev, pm_message_t mesg)
|
||||
{
|
||||
struct spi_master *master = platform_get_drvdata(pdev);
|
||||
struct rk2818_spi *dws = spi_master_get_devdata(master);
|
||||
struct rk2818_spi_platform_data *pdata = pdev->dev.platform_data;
|
||||
int status;
|
||||
|
||||
status = stop_queue(dws);
|
||||
if (status != 0)
|
||||
return status;
|
||||
clk_disable(dws->clock_spim);
|
||||
|
||||
if (pdata && pdata->io_fix_leakage_bug)
|
||||
{
|
||||
pdata->io_fix_leakage_bug( );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1465,6 +1469,7 @@ static int rk2818_spim_resume(struct platform_device *pdev)
|
||||
{
|
||||
struct spi_master *master = platform_get_drvdata(pdev);
|
||||
struct rk2818_spi *dws = spi_master_get_devdata(master);
|
||||
struct rk2818_spi_platform_data *pdata = pdev->dev.platform_data;
|
||||
int ret;
|
||||
|
||||
clk_enable(dws->clock_spim);
|
||||
@@ -1472,6 +1477,10 @@ static int rk2818_spim_resume(struct platform_device *pdev)
|
||||
ret = start_queue(dws);
|
||||
if (ret)
|
||||
dev_err(&dws->master->dev, "fail to start queue (%d)\n", ret);
|
||||
if (pdata && pdata->io_resume_leakage_bug)
|
||||
{
|
||||
pdata->io_resume_leakage_bug( );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user