mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-10-22 23:23:03 +02:00
drivers: gpio: qixis-cpld: extend support also for the LS1046AQDS QIXIS CPLD
Extend the driver to also support the GPIO controller found on the LS1046AQDS QIXIS CPLD. For usecases in which the parent device (the QIXIS CPLD) does not define a regmap for its memory area, create the driver's own regmap which will get passed to gpio-regmap trough devm_gpio_regmap_register(). In this case, the offset inside of the regmap will be zero since the regmap points directly to the desired register. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
This commit is contained in:
parent
4827f20b80
commit
34bbf282e3
|
@ -16,6 +16,7 @@
|
|||
|
||||
enum qixis_cpld_gpio_type {
|
||||
LX2160ARDB_CPLD_GPIO = 0,
|
||||
LS1046AQDS_STAT_PRES2_CPLD_GPIO,
|
||||
};
|
||||
|
||||
struct qixis_cpld_gpio_config {
|
||||
|
@ -28,6 +29,11 @@ static struct qixis_cpld_gpio_config lx2160ardb_cpld_gpio_cfg = {
|
|||
.input_lines = GENMASK(7, 1),
|
||||
};
|
||||
|
||||
static struct qixis_cpld_gpio_config ls1046aqds_stat_pres2_cpld_gpio_cfg = {
|
||||
.type = LS1046AQDS_STAT_PRES2_CPLD_GPIO,
|
||||
.input_lines = GENMASK(7, 0),
|
||||
};
|
||||
|
||||
static int qixis_cpld_gpio_get_direction(struct gpio_regmap *gpio, unsigned int offset)
|
||||
{
|
||||
struct qixis_cpld_gpio_config *cfg = gpio_regmap_get_drvdata(gpio);
|
||||
|
@ -38,11 +44,17 @@ static int qixis_cpld_gpio_get_direction(struct gpio_regmap *gpio, unsigned int
|
|||
return GPIO_LINE_DIRECTION_OUT;
|
||||
}
|
||||
|
||||
static const struct regmap_config regmap_config_8r_8v = {
|
||||
.reg_bits = 8,
|
||||
.val_bits = 8,
|
||||
};
|
||||
|
||||
static int qixis_cpld_gpio_probe(struct platform_device *pdev)
|
||||
{
|
||||
const struct qixis_cpld_gpio_config *cfg;
|
||||
struct gpio_regmap_config config = {0};
|
||||
struct regmap *regmap;
|
||||
void __iomem *reg;
|
||||
u32 base;
|
||||
int ret;
|
||||
|
||||
|
@ -58,8 +70,23 @@ static int qixis_cpld_gpio_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
|
||||
regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
||||
if (!regmap)
|
||||
return -ENODEV;
|
||||
if (!regmap) {
|
||||
/* In case there is no regmap configured by the parent device,
|
||||
* create our own.
|
||||
*/
|
||||
reg = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (!reg)
|
||||
return -ENODEV;
|
||||
|
||||
regmap = devm_regmap_init_mmio(&pdev->dev, reg, ®map_config_8r_8v);
|
||||
if (!regmap)
|
||||
return -ENODEV;
|
||||
|
||||
/* In this case, the offset of our register is 0 inside the
|
||||
* regmap area that we just created.
|
||||
*/
|
||||
base = 0;
|
||||
}
|
||||
|
||||
config.get_direction = qixis_cpld_gpio_get_direction;
|
||||
config.drvdata = (void *)cfg;
|
||||
|
@ -84,6 +111,11 @@ static const struct of_device_id qixis_cpld_gpio_of_match[] = {
|
|||
.compatible = "fsl,lx2160a-rdb-qixis-cpld-gpio",
|
||||
.data = &lx2160ardb_cpld_gpio_cfg
|
||||
},
|
||||
{
|
||||
.compatible = "fsl,ls1046a-qds-qixis-stat-pres2-cpld-gpio",
|
||||
.data = &ls1046aqds_stat_pres2_cpld_gpio_cfg
|
||||
},
|
||||
|
||||
{}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, qixis_cpld_gpio_of_match);
|
||||
|
|
Loading…
Reference in New Issue
Block a user