Skip to content
Permalink
Browse files
gpio: msc313: Add irq support for ssd20xd
The SSD201, SSD202D and newer chips use a special interrupt
controller for GPIOS.

Add a new mapping function for these chips.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
  • Loading branch information
fifteenhex committed Dec 13, 2021
1 parent 221a7a2 commit a49bf8bf6981c5b4f5c0dbb89e216ed0537172dc
Showing 1 changed file with 34 additions and 1 deletion.
@@ -486,7 +486,9 @@ static const unsigned int ssd20xd_offsets[] = {
SSD20XD_GPIO_OFFSETS,
};

MSC313_GPIO_CHIPDATA(ssd20xd);
static int ssd20xd_gpio_child_to_parent_hwirq(struct gpio_chip *, unsigned int,
unsigned int, unsigned int*, unsigned int*);
MSC313_GPIO_CHIPDATA(ssd20xd, gpiochip_populate_parent_fwspec_twocell, ssd20xd_gpio_child_to_parent_hwirq);
#endif

struct msc313_gpio {
@@ -602,6 +604,37 @@ static int msc313e_gpio_child_to_parent_hwirq(struct gpio_chip *chip,
return -EINVAL;
}

static int ssd20xd_gpio_child_to_parent_hwirq(struct gpio_chip *chip,
unsigned int child,
unsigned int child_type,
unsigned int *parent,
unsigned int *parent_type)
{
struct msc313_gpio *priv = gpiochip_get_data(chip);
unsigned int offset = priv->gpio_data->offsets[child];

*parent_type = child_type;

/*
* On the ssd20xd chips a lot more pins are interrupt enabled but it
* still isn't a linear mapping and not all pins are wired up.
*/
if (offset >= SSD20XD_TTL_OFFSET_TTL0 && offset <= SSD20XD_TTL_OFFSET_TTL27){
*parent = ((offset - SSD20XD_TTL_OFFSET_TTL0) >> 2) + 4;
return 0;
}
else if (offset >= SSD20XD_GPIO_OFF_GPIO0 && offset <= SSD20XD_GPIO_OFF_GPIO14){
*parent = ((offset - SSD20XD_GPIO_OFF_GPIO0) >> 2) + 45;
return 0;
}
else if (offset >= OFF_FUART_RX && offset <= OFF_FUART_RTS){
*parent = ((offset - OFF_FUART_RX) >> 2) + 60;
return 0;
}

return -EINVAL;
}

static int msc313_gpio_probe(struct platform_device *pdev)
{
const struct msc313_gpio_data *match_data;

0 comments on commit a49bf8b

Please sign in to comment.