Commit 28538df0 authored by Wolfram Sang's avatar Wolfram Sang Committed by Grant Likely

gpio: mpc8xxx: don't allow input-only pins to be output for MPC5121

Add a 5121-custom reject if an input-only pin is requested to be output
(see 18.3.1.1 in the refman). Also, rewrite mach-specific quirk setup to
consume less lines which scales better.
Signed-off-by: default avatarWolfram Sang <w.sang@pengutronix.de>
[grant.likely: Fixed build error]
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 4d052213
...@@ -132,6 +132,15 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val ...@@ -132,6 +132,15 @@ static int mpc8xxx_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val
return 0; return 0;
} }
static int mpc5121_gpio_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
{
/* GPIO 28..31 are input only on MPC5121 */
if (gpio >= 28)
return -EINVAL;
return mpc8xxx_gpio_dir_out(gc, gpio, val);
}
static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset)
{ {
struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc); struct of_mm_gpio_chip *mm = to_of_mm_gpio_chip(gc);
...@@ -340,11 +349,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np) ...@@ -340,11 +349,10 @@ static void __init mpc8xxx_add_controller(struct device_node *np)
mm_gc->save_regs = mpc8xxx_gpio_save_regs; mm_gc->save_regs = mpc8xxx_gpio_save_regs;
gc->ngpio = MPC8XXX_GPIO_PINS; gc->ngpio = MPC8XXX_GPIO_PINS;
gc->direction_input = mpc8xxx_gpio_dir_in; gc->direction_input = mpc8xxx_gpio_dir_in;
gc->direction_output = mpc8xxx_gpio_dir_out; gc->direction_output = of_device_is_compatible(np, "fsl,mpc5121-gpio") ?
if (of_device_is_compatible(np, "fsl,mpc8572-gpio")) mpc5121_gpio_dir_out : mpc8xxx_gpio_dir_out;
gc->get = mpc8572_gpio_get; gc->get = of_device_is_compatible(np, "fsl,mpc8572-gpio") ?
else mpc8572_gpio_get : mpc8xxx_gpio_get;
gc->get = mpc8xxx_gpio_get;
gc->set = mpc8xxx_gpio_set; gc->set = mpc8xxx_gpio_set;
gc->to_irq = mpc8xxx_gpio_to_irq; gc->to_irq = mpc8xxx_gpio_to_irq;
......
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