Commit 767d8336 authored by Linus Walleij's avatar Linus Walleij

Input: ads7846 - Convert to use software nodes

The Nokia 770 is using GPIOs from the global numberspace on the
CBUS node to pass down to the LCD controller. This regresses when we
let the OMAP GPIO driver use dynamic GPIO base.

The Nokia 770 now has dynamic allocation of IRQ numbers, so this
needs to be fixed for it to work.

As this is the only user of LCD MIPID we can easily augment the
driver to use a GPIO descriptor instead and resolve the issue.

The platform data .shutdown() callback wasn't even used in the
code, but we encode a shutdown asserting RESET in the remove()
callback for completeness sake.

The CBUS also has the ADS7846 touchscreen attached.

Populate the devices on the Nokia 770 CBUS I2C using software
nodes instead of platform data quirks. This includes the LCD
and the ADS7846 touchscreen so the conversion just brings the LCD
along with it as software nodes is an all-or-nothing design
pattern.

The ADS7846 has some limited support for using GPIO descriptors,
let's convert it over completely to using device properties and then
fix all remaining boardfile users to provide all platform data using
software nodes.

Dump the of includes and of_match_ptr() in the ADS7846 driver as part
of the job.

Since we have to move ADS7846 over to obtaining the GPIOs it is
using exclusively from descriptors, we provide descriptor tables
for the two remaining in-kernel boardfiles using ADS7846:

- PXA Spitz
- MIPS Alchemy DB1000 development board

It was too hard for me to include software node conversion of
these two remaining users at this time: the spitz is using a
hscync callback in the platform data that would require further
GPIO descriptor conversion of the Spitz, and moving the hsync
callback down into the driver: it will just become too big of
a job, but it can be done separately.

The MIPS Alchemy DB1000 is simply something I cannot test, so take
the easier approach of just providing some GPIO descriptors in
this case as I don't want the patch to grow too intrusive.

As we see that several device trees have incorrect polarity flags
and just expect to bypass the gpiolib polarity handling, fix up
all device trees too, in a separate patch.
Suggested-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Fixes: 92bf78b3 ("gpio: omap: use dynamic allocation of base")
Acked-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 480c82da
...@@ -8,15 +8,16 @@ ...@@ -8,15 +8,16 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/machine.h> #include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/input.h> #include <linux/input.h>
#include <linux/omapfb.h> #include <linux/omapfb.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -35,6 +36,25 @@ ...@@ -35,6 +36,25 @@
#include "clock.h" #include "clock.h"
#include "mmc.h" #include "mmc.h"
static const struct software_node nokia770_mpuio_gpiochip_node = {
.name = "mpuio",
};
static const struct software_node nokia770_gpiochip1_node = {
.name = "gpio-0-15",
};
static const struct software_node nokia770_gpiochip2_node = {
.name = "gpio-16-31",
};
static const struct software_node *nokia770_gpiochip_nodes[] = {
&nokia770_mpuio_gpiochip_node,
&nokia770_gpiochip1_node,
&nokia770_gpiochip2_node,
NULL
};
#define ADS7846_PENDOWN_GPIO 15 #define ADS7846_PENDOWN_GPIO 15
static const unsigned int nokia770_keymap[] = { static const unsigned int nokia770_keymap[] = {
...@@ -85,40 +105,47 @@ static struct platform_device *nokia770_devices[] __initdata = { ...@@ -85,40 +105,47 @@ static struct platform_device *nokia770_devices[] __initdata = {
&nokia770_kp_device, &nokia770_kp_device,
}; };
static void mipid_shutdown(struct mipid_platform_data *pdata) static struct mipid_platform_data nokia770_mipid_platform_data = { };
{
if (pdata->nreset_gpio != -1) {
printk(KERN_INFO "shutdown LCD\n");
gpio_set_value(pdata->nreset_gpio, 0);
msleep(120);
}
}
static struct mipid_platform_data nokia770_mipid_platform_data = {
.shutdown = mipid_shutdown,
};
static const struct omap_lcd_config nokia770_lcd_config __initconst = { static const struct omap_lcd_config nokia770_lcd_config __initconst = {
.ctrl_name = "hwa742", .ctrl_name = "hwa742",
}; };
static const struct property_entry nokia770_mipid_props[] = {
PROPERTY_ENTRY_GPIO("reset-gpios", &nokia770_gpiochip1_node,
13, GPIO_ACTIVE_LOW),
{ }
};
static const struct software_node nokia770_mipid_swnode = {
.name = "lcd_mipid",
.properties = nokia770_mipid_props,
};
static void __init mipid_dev_init(void) static void __init mipid_dev_init(void)
{ {
nokia770_mipid_platform_data.nreset_gpio = 13;
nokia770_mipid_platform_data.data_lines = 16; nokia770_mipid_platform_data.data_lines = 16;
omapfb_set_lcd_config(&nokia770_lcd_config); omapfb_set_lcd_config(&nokia770_lcd_config);
} }
static struct ads7846_platform_data nokia770_ads7846_platform_data __initdata = { static const struct property_entry nokia770_ads7846_props[] = {
.x_max = 0x0fff, PROPERTY_ENTRY_STRING("compatible", "ti,ads7846"),
.y_max = 0x0fff, PROPERTY_ENTRY_U32("touchscreen-size-x", 4096),
.x_plate_ohms = 180, PROPERTY_ENTRY_U32("touchscreen-size-y", 4096),
.pressure_max = 255, PROPERTY_ENTRY_U32("touchscreen-max-pressure", 256),
.debounce_max = 10, PROPERTY_ENTRY_U32("touchscreen-average-samples", 10),
.debounce_tol = 3, PROPERTY_ENTRY_U16("ti,x-plate-ohms", 180),
.debounce_rep = 1, PROPERTY_ENTRY_U16("ti,debounce-tol", 3),
.gpio_pendown = ADS7846_PENDOWN_GPIO, PROPERTY_ENTRY_U16("ti,debounce-rep", 1),
PROPERTY_ENTRY_GPIO("pendown-gpios", &nokia770_gpiochip1_node,
ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW),
{ }
};
static const struct software_node nokia770_ads7846_swnode = {
.name = "ads7846",
.properties = nokia770_ads7846_props,
}; };
static struct spi_board_info nokia770_spi_board_info[] __initdata = { static struct spi_board_info nokia770_spi_board_info[] __initdata = {
...@@ -128,13 +155,14 @@ static struct spi_board_info nokia770_spi_board_info[] __initdata = { ...@@ -128,13 +155,14 @@ static struct spi_board_info nokia770_spi_board_info[] __initdata = {
.chip_select = 3, .chip_select = 3,
.max_speed_hz = 12000000, .max_speed_hz = 12000000,
.platform_data = &nokia770_mipid_platform_data, .platform_data = &nokia770_mipid_platform_data,
.swnode = &nokia770_mipid_swnode,
}, },
[1] = { [1] = {
.modalias = "ads7846", .modalias = "ads7846",
.bus_num = 2, .bus_num = 2,
.chip_select = 0, .chip_select = 0,
.max_speed_hz = 2500000, .max_speed_hz = 2500000,
.platform_data = &nokia770_ads7846_platform_data, .swnode = &nokia770_ads7846_swnode,
}, },
}; };
...@@ -212,14 +240,16 @@ static inline void nokia770_mmc_init(void) ...@@ -212,14 +240,16 @@ static inline void nokia770_mmc_init(void)
#endif #endif
#if IS_ENABLED(CONFIG_I2C_CBUS_GPIO) #if IS_ENABLED(CONFIG_I2C_CBUS_GPIO)
static struct gpiod_lookup_table nokia770_cbus_gpio_table = {
.dev_id = "i2c-cbus-gpio.2", static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = {
.table = { SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 9, 0),
GPIO_LOOKUP_IDX("mpuio", 9, NULL, 0, 0), /* clk */ SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 10, 0),
GPIO_LOOKUP_IDX("mpuio", 10, NULL, 1, 0), /* dat */ SOFTWARE_NODE_REFERENCE(&nokia770_mpuio_gpiochip_node, 11, 0),
GPIO_LOOKUP_IDX("mpuio", 11, NULL, 2, 0), /* sel */ };
{ },
}, static const struct property_entry nokia770_cbus_props[] = {
PROPERTY_ENTRY_REF_ARRAY("gpios", nokia770_cbus_gpio_refs),
{ }
}; };
static struct platform_device nokia770_cbus_device = { static struct platform_device nokia770_cbus_device = {
...@@ -253,7 +283,8 @@ static void __init nokia770_cbus_init(void) ...@@ -253,7 +283,8 @@ static void __init nokia770_cbus_init(void)
nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio); nokia770_i2c_board_info_2[1].irq = gpio_to_irq(tahvo_irq_gpio);
i2c_register_board_info(2, nokia770_i2c_board_info_2, i2c_register_board_info(2, nokia770_i2c_board_info_2,
ARRAY_SIZE(nokia770_i2c_board_info_2)); ARRAY_SIZE(nokia770_i2c_board_info_2));
gpiod_add_lookup_table(&nokia770_cbus_gpio_table); device_create_managed_software_node(&nokia770_cbus_device.dev,
nokia770_cbus_props, NULL);
platform_device_register(&nokia770_cbus_device); platform_device_register(&nokia770_cbus_device);
} }
#else /* CONFIG_I2C_CBUS_GPIO */ #else /* CONFIG_I2C_CBUS_GPIO */
...@@ -273,8 +304,8 @@ static void __init omap_nokia770_init(void) ...@@ -273,8 +304,8 @@ static void __init omap_nokia770_init(void)
/* Unmask SleepX signal */ /* Unmask SleepX signal */
omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004); omap_writew((omap_readw(0xfffb5004) & ~2), 0xfffb5004);
software_node_register_node_group(nokia770_gpiochip_nodes);
platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices)); platform_add_devices(nokia770_devices, ARRAY_SIZE(nokia770_devices));
nokia770_spi_board_info[1].irq = gpio_to_irq(15);
spi_register_board_info(nokia770_spi_board_info, spi_register_board_info(nokia770_spi_board_info,
ARRAY_SIZE(nokia770_spi_board_info)); ARRAY_SIZE(nokia770_spi_board_info));
omap_serial_init(); omap_serial_init();
......
...@@ -506,10 +506,18 @@ static struct ads7846_platform_data spitz_ads7846_info = { ...@@ -506,10 +506,18 @@ static struct ads7846_platform_data spitz_ads7846_info = {
.x_plate_ohms = 419, .x_plate_ohms = 419,
.y_plate_ohms = 486, .y_plate_ohms = 486,
.pressure_max = 1024, .pressure_max = 1024,
.gpio_pendown = SPITZ_GPIO_TP_INT,
.wait_for_sync = spitz_ads7846_wait_for_hsync, .wait_for_sync = spitz_ads7846_wait_for_hsync,
}; };
static struct gpiod_lookup_table spitz_ads7846_gpio_table = {
.dev_id = "spi2.0",
.table = {
GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_TP_INT,
"pendown", GPIO_ACTIVE_LOW),
{ }
},
};
static void spitz_bl_kick_battery(void) static void spitz_bl_kick_battery(void)
{ {
void (*kick_batt)(void); void (*kick_batt)(void);
...@@ -594,6 +602,7 @@ static void __init spitz_spi_init(void) ...@@ -594,6 +602,7 @@ static void __init spitz_spi_init(void)
else else
gpiod_add_lookup_table(&spitz_lcdcon_gpio_table); gpiod_add_lookup_table(&spitz_lcdcon_gpio_table);
gpiod_add_lookup_table(&spitz_ads7846_gpio_table);
gpiod_add_lookup_table(&spitz_spi_gpio_table); gpiod_add_lookup_table(&spitz_spi_gpio_table);
pxa2xx_set_spi_info(2, &spitz_spi_info); pxa2xx_set_spi_info(2, &spitz_spi_info);
spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
......
...@@ -381,13 +381,21 @@ static struct platform_device db1100_mmc1_dev = { ...@@ -381,13 +381,21 @@ static struct platform_device db1100_mmc1_dev = {
static struct ads7846_platform_data db1100_touch_pd = { static struct ads7846_platform_data db1100_touch_pd = {
.model = 7846, .model = 7846,
.vref_mv = 3300, .vref_mv = 3300,
.gpio_pendown = 21,
}; };
static struct spi_gpio_platform_data db1100_spictl_pd = { static struct spi_gpio_platform_data db1100_spictl_pd = {
.num_chipselect = 1, .num_chipselect = 1,
}; };
static struct gpiod_lookup_table db1100_touch_gpio_table = {
.dev_id = "spi0.0",
.table = {
GPIO_LOOKUP("alchemy-gpio2", 21,
"pendown", GPIO_ACTIVE_LOW),
{ }
},
};
static struct spi_board_info db1100_spi_info[] __initdata = { static struct spi_board_info db1100_spi_info[] __initdata = {
[0] = { [0] = {
.modalias = "ads7846", .modalias = "ads7846",
...@@ -474,6 +482,7 @@ int __init db1000_dev_setup(void) ...@@ -474,6 +482,7 @@ int __init db1000_dev_setup(void)
pfc |= (1 << 0); /* SSI0 pins as GPIOs */ pfc |= (1 << 0); /* SSI0 pins as GPIOs */
alchemy_wrsys(pfc, AU1000_SYS_PINFUNC); alchemy_wrsys(pfc, AU1000_SYS_PINFUNC);
gpiod_add_lookup_table(&db1100_touch_gpio_table);
spi_register_board_info(db1100_spi_info, spi_register_board_info(db1100_spi_info,
ARRAY_SIZE(db1100_spi_info)); ARRAY_SIZE(db1100_spi_info));
......
...@@ -24,11 +24,8 @@ ...@@ -24,11 +24,8 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/of.h> #include <linux/property.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/gpio.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/ads7846.h> #include <linux/spi/ads7846.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
...@@ -140,7 +137,7 @@ struct ads7846 { ...@@ -140,7 +137,7 @@ struct ads7846 {
int (*filter)(void *data, int data_idx, int *val); int (*filter)(void *data, int data_idx, int *val);
void *filter_data; void *filter_data;
int (*get_pendown_state)(void); int (*get_pendown_state)(void);
int gpio_pendown; struct gpio_desc *gpio_pendown;
void (*wait_for_sync)(void); void (*wait_for_sync)(void);
}; };
...@@ -223,7 +220,7 @@ static int get_pendown_state(struct ads7846 *ts) ...@@ -223,7 +220,7 @@ static int get_pendown_state(struct ads7846 *ts)
if (ts->get_pendown_state) if (ts->get_pendown_state)
return ts->get_pendown_state(); return ts->get_pendown_state();
return !gpio_get_value(ts->gpio_pendown); return gpiod_get_value(ts->gpio_pendown);
} }
static void ads7846_report_pen_up(struct ads7846 *ts) static void ads7846_report_pen_up(struct ads7846 *ts)
...@@ -989,8 +986,6 @@ static int ads7846_setup_pendown(struct spi_device *spi, ...@@ -989,8 +986,6 @@ static int ads7846_setup_pendown(struct spi_device *spi,
struct ads7846 *ts, struct ads7846 *ts,
const struct ads7846_platform_data *pdata) const struct ads7846_platform_data *pdata)
{ {
int err;
/* /*
* REVISIT when the irq can be triggered active-low, or if for some * REVISIT when the irq can be triggered active-low, or if for some
* reason the touchscreen isn't hooked up, we don't need to access * reason the touchscreen isn't hooked up, we don't need to access
...@@ -999,25 +994,15 @@ static int ads7846_setup_pendown(struct spi_device *spi, ...@@ -999,25 +994,15 @@ static int ads7846_setup_pendown(struct spi_device *spi,
if (pdata->get_pendown_state) { if (pdata->get_pendown_state) {
ts->get_pendown_state = pdata->get_pendown_state; ts->get_pendown_state = pdata->get_pendown_state;
} else if (gpio_is_valid(pdata->gpio_pendown)) { } else {
ts->gpio_pendown = gpiod_get(&spi->dev, "pendown", GPIOD_IN);
err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown, if (IS_ERR(ts->gpio_pendown)) {
GPIOF_IN, "ads7846_pendown"); dev_err(&spi->dev, "failed to request pendown GPIO\n");
if (err) { return PTR_ERR(ts->gpio_pendown);
dev_err(&spi->dev,
"failed to request/setup pendown GPIO%d: %d\n",
pdata->gpio_pendown, err);
return err;
} }
ts->gpio_pendown = pdata->gpio_pendown;
if (pdata->gpio_pendown_debounce) if (pdata->gpio_pendown_debounce)
gpiod_set_debounce(gpio_to_desc(ts->gpio_pendown), gpiod_set_debounce(ts->gpio_pendown,
pdata->gpio_pendown_debounce); pdata->gpio_pendown_debounce);
} else {
dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
return -EINVAL;
} }
return 0; return 0;
...@@ -1119,7 +1104,6 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts, ...@@ -1119,7 +1104,6 @@ static int ads7846_setup_spi_msg(struct ads7846 *ts,
return 0; return 0;
} }
#ifdef CONFIG_OF
static const struct of_device_id ads7846_dt_ids[] = { static const struct of_device_id ads7846_dt_ids[] = {
{ .compatible = "ti,tsc2046", .data = (void *) 7846 }, { .compatible = "ti,tsc2046", .data = (void *) 7846 },
{ .compatible = "ti,ads7843", .data = (void *) 7843 }, { .compatible = "ti,ads7843", .data = (void *) 7843 },
...@@ -1130,20 +1114,14 @@ static const struct of_device_id ads7846_dt_ids[] = { ...@@ -1130,20 +1114,14 @@ static const struct of_device_id ads7846_dt_ids[] = {
}; };
MODULE_DEVICE_TABLE(of, ads7846_dt_ids); MODULE_DEVICE_TABLE(of, ads7846_dt_ids);
static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) static const struct ads7846_platform_data *ads7846_get_props(struct device *dev)
{ {
struct ads7846_platform_data *pdata; struct ads7846_platform_data *pdata;
struct device_node *node = dev->of_node; const struct platform_device_id *pdev_id;
const struct of_device_id *match;
u32 value; u32 value;
if (!node) { pdev_id = device_get_match_data(dev);
dev_err(dev, "Device does not have associated DT data\n"); if (!pdev_id) {
return ERR_PTR(-EINVAL);
}
match = of_match_device(ads7846_dt_ids, dev);
if (!match) {
dev_err(dev, "Unknown device model\n"); dev_err(dev, "Unknown device model\n");
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -1152,60 +1130,51 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev) ...@@ -1152,60 +1130,51 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
if (!pdata) if (!pdata)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
pdata->model = (unsigned long)match->data; pdata->model = (unsigned long)pdev_id->driver_data;
of_property_read_u16(node, "ti,vref-delay-usecs", device_property_read_u16(dev, "ti,vref-delay-usecs",
&pdata->vref_delay_usecs); &pdata->vref_delay_usecs);
of_property_read_u16(node, "ti,vref-mv", &pdata->vref_mv); device_property_read_u16(dev, "ti,vref-mv", &pdata->vref_mv);
pdata->keep_vref_on = of_property_read_bool(node, "ti,keep-vref-on"); pdata->keep_vref_on = device_property_read_bool(dev, "ti,keep-vref-on");
pdata->swap_xy = of_property_read_bool(node, "ti,swap-xy"); pdata->swap_xy = device_property_read_bool(dev, "ti,swap-xy");
of_property_read_u16(node, "ti,settle-delay-usec", device_property_read_u16(dev, "ti,settle-delay-usec",
&pdata->settle_delay_usecs); &pdata->settle_delay_usecs);
of_property_read_u16(node, "ti,penirq-recheck-delay-usecs", device_property_read_u16(dev, "ti,penirq-recheck-delay-usecs",
&pdata->penirq_recheck_delay_usecs); &pdata->penirq_recheck_delay_usecs);
of_property_read_u16(node, "ti,x-plate-ohms", &pdata->x_plate_ohms); device_property_read_u16(dev, "ti,x-plate-ohms", &pdata->x_plate_ohms);
of_property_read_u16(node, "ti,y-plate-ohms", &pdata->y_plate_ohms); device_property_read_u16(dev, "ti,y-plate-ohms", &pdata->y_plate_ohms);
of_property_read_u16(node, "ti,x-min", &pdata->x_min); device_property_read_u16(dev, "ti,x-min", &pdata->x_min);
of_property_read_u16(node, "ti,y-min", &pdata->y_min); device_property_read_u16(dev, "ti,y-min", &pdata->y_min);
of_property_read_u16(node, "ti,x-max", &pdata->x_max); device_property_read_u16(dev, "ti,x-max", &pdata->x_max);
of_property_read_u16(node, "ti,y-max", &pdata->y_max); device_property_read_u16(dev, "ti,y-max", &pdata->y_max);
/* /*
* touchscreen-max-pressure gets parsed during * touchscreen-max-pressure gets parsed during
* touchscreen_parse_properties() * touchscreen_parse_properties()
*/ */
of_property_read_u16(node, "ti,pressure-min", &pdata->pressure_min); device_property_read_u16(dev, "ti,pressure-min", &pdata->pressure_min);
if (!of_property_read_u32(node, "touchscreen-min-pressure", &value)) if (!device_property_read_u32(dev, "touchscreen-min-pressure", &value))
pdata->pressure_min = (u16) value; pdata->pressure_min = (u16) value;
of_property_read_u16(node, "ti,pressure-max", &pdata->pressure_max); device_property_read_u16(dev, "ti,pressure-max", &pdata->pressure_max);
of_property_read_u16(node, "ti,debounce-max", &pdata->debounce_max); device_property_read_u16(dev, "ti,debounce-max", &pdata->debounce_max);
if (!of_property_read_u32(node, "touchscreen-average-samples", &value)) if (!device_property_read_u32(dev, "touchscreen-average-samples", &value))
pdata->debounce_max = (u16) value; pdata->debounce_max = (u16) value;
of_property_read_u16(node, "ti,debounce-tol", &pdata->debounce_tol); device_property_read_u16(dev, "ti,debounce-tol", &pdata->debounce_tol);
of_property_read_u16(node, "ti,debounce-rep", &pdata->debounce_rep); device_property_read_u16(dev, "ti,debounce-rep", &pdata->debounce_rep);
of_property_read_u32(node, "ti,pendown-gpio-debounce", device_property_read_u32(dev, "ti,pendown-gpio-debounce",
&pdata->gpio_pendown_debounce); &pdata->gpio_pendown_debounce);
pdata->wakeup = of_property_read_bool(node, "wakeup-source") || pdata->wakeup = device_property_read_bool(dev, "wakeup-source") ||
of_property_read_bool(node, "linux,wakeup"); device_property_read_bool(dev, "linux,wakeup");
pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
return pdata; return pdata;
} }
#else
static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
{
dev_err(dev, "no platform data defined\n");
return ERR_PTR(-EINVAL);
}
#endif
static void ads7846_regulator_disable(void *regulator) static void ads7846_regulator_disable(void *regulator)
{ {
...@@ -1269,7 +1238,7 @@ static int ads7846_probe(struct spi_device *spi) ...@@ -1269,7 +1238,7 @@ static int ads7846_probe(struct spi_device *spi)
pdata = dev_get_platdata(dev); pdata = dev_get_platdata(dev);
if (!pdata) { if (!pdata) {
pdata = ads7846_probe_dt(dev); pdata = ads7846_get_props(dev);
if (IS_ERR(pdata)) if (IS_ERR(pdata))
return PTR_ERR(pdata); return PTR_ERR(pdata);
} }
...@@ -1426,7 +1395,7 @@ static struct spi_driver ads7846_driver = { ...@@ -1426,7 +1395,7 @@ static struct spi_driver ads7846_driver = {
.driver = { .driver = {
.name = "ads7846", .name = "ads7846",
.pm = pm_sleep_ptr(&ads7846_pm), .pm = pm_sleep_ptr(&ads7846_pm),
.of_match_table = of_match_ptr(ads7846_dt_ids), .of_match_table = ads7846_dt_ids,
}, },
.probe = ads7846_probe, .probe = ads7846_probe,
.remove = ads7846_remove, .remove = ads7846_remove,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/device.h> #include <linux/device.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
...@@ -41,6 +42,7 @@ struct mipid_device { ...@@ -41,6 +42,7 @@ struct mipid_device {
when we can issue the when we can issue the
next sleep in/out command */ next sleep in/out command */
unsigned long hw_guard_wait; /* max guard time in jiffies */ unsigned long hw_guard_wait; /* max guard time in jiffies */
struct gpio_desc *reset;
struct omapfb_device *fbdev; struct omapfb_device *fbdev;
struct spi_device *spi; struct spi_device *spi;
...@@ -556,6 +558,12 @@ static int mipid_spi_probe(struct spi_device *spi) ...@@ -556,6 +558,12 @@ static int mipid_spi_probe(struct spi_device *spi)
return -ENOMEM; return -ENOMEM;
} }
/* This will de-assert RESET if active */
md->reset = gpiod_get(&spi->dev, "reset", GPIOD_OUT_LOW);
if (IS_ERR(md->reset))
return dev_err_probe(&spi->dev, PTR_ERR(md->reset),
"no reset GPIO line\n");
spi->mode = SPI_MODE_0; spi->mode = SPI_MODE_0;
md->spi = spi; md->spi = spi;
dev_set_drvdata(&spi->dev, md); dev_set_drvdata(&spi->dev, md);
...@@ -574,6 +582,8 @@ static void mipid_spi_remove(struct spi_device *spi) ...@@ -574,6 +582,8 @@ static void mipid_spi_remove(struct spi_device *spi)
{ {
struct mipid_device *md = dev_get_drvdata(&spi->dev); struct mipid_device *md = dev_get_drvdata(&spi->dev);
/* Asserts RESET */
gpiod_set_value(md->reset, 1);
mipid_disable(&md->panel); mipid_disable(&md->panel);
kfree(md); kfree(md);
} }
......
...@@ -15,10 +15,8 @@ enum mipid_test_result { ...@@ -15,10 +15,8 @@ enum mipid_test_result {
#ifdef __KERNEL__ #ifdef __KERNEL__
struct mipid_platform_data { struct mipid_platform_data {
int nreset_gpio;
int data_lines; int data_lines;
void (*shutdown)(struct mipid_platform_data *pdata);
void (*set_bklight_level)(struct mipid_platform_data *pdata, void (*set_bklight_level)(struct mipid_platform_data *pdata,
int level); int level);
int (*get_bklight_level)(struct mipid_platform_data *pdata); int (*get_bklight_level)(struct mipid_platform_data *pdata);
......
...@@ -35,8 +35,6 @@ struct ads7846_platform_data { ...@@ -35,8 +35,6 @@ struct ads7846_platform_data {
u16 debounce_tol; /* tolerance used for filtering */ u16 debounce_tol; /* tolerance used for filtering */
u16 debounce_rep; /* additional consecutive good readings u16 debounce_rep; /* additional consecutive good readings
* required after the first two */ * required after the first two */
int gpio_pendown; /* the GPIO used to decide the pendown
* state if get_pendown_state == NULL */
int gpio_pendown_debounce; /* platform specific debounce time for int gpio_pendown_debounce; /* platform specific debounce time for
* the gpio_pendown */ * the gpio_pendown */
int (*get_pendown_state)(void); int (*get_pendown_state)(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment