Commit e5a4ab6a authored by Andy Shevchenko's avatar Andy Shevchenko

pinctrl: intel: Introduce common flags for GPIO mapping scheme

Few drivers are using the same flag to tell Intel pin control core
how to interpret GPIO base.

Provide a generic flags so all drivers can use.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 5707dd73
...@@ -798,7 +798,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset, ...@@ -798,7 +798,7 @@ static int intel_gpio_to_pin(struct intel_pinctrl *pctrl, unsigned int offset,
for (j = 0; j < comm->ngpps; j++) { for (j = 0; j < comm->ngpps; j++) {
const struct intel_padgroup *pgrp = &comm->gpps[j]; const struct intel_padgroup *pgrp = &comm->gpps[j];
if (pgrp->gpio_base < 0) if (pgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
continue; continue;
if (offset >= pgrp->gpio_base && if (offset >= pgrp->gpio_base &&
...@@ -1138,7 +1138,7 @@ static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl, ...@@ -1138,7 +1138,7 @@ static int intel_gpio_add_community_ranges(struct intel_pinctrl *pctrl,
for (i = 0; i < community->ngpps; i++) { for (i = 0; i < community->ngpps; i++) {
const struct intel_padgroup *gpp = &community->gpps[i]; const struct intel_padgroup *gpp = &community->gpps[i];
if (gpp->gpio_base < 0) if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP)
continue; continue;
ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev), ret = gpiochip_add_pin_range(&pctrl->chip, dev_name(pctrl->dev),
...@@ -1180,7 +1180,7 @@ static unsigned int intel_gpio_ngpio(const struct intel_pinctrl *pctrl) ...@@ -1180,7 +1180,7 @@ static unsigned int intel_gpio_ngpio(const struct intel_pinctrl *pctrl)
for (j = 0; j < community->ngpps; j++) { for (j = 0; j < community->ngpps; j++) {
const struct intel_padgroup *gpp = &community->gpps[j]; const struct intel_padgroup *gpp = &community->gpps[j];
if (gpp->gpio_base < 0) if (gpp->gpio_base == INTEL_GPIO_BASE_NOMAP)
continue; continue;
if (gpp->gpio_base + gpp->size > ngpio) if (gpp->gpio_base + gpp->size > ngpio)
...@@ -1276,8 +1276,15 @@ static int intel_pinctrl_add_padgroups(struct intel_pinctrl *pctrl, ...@@ -1276,8 +1276,15 @@ static int intel_pinctrl_add_padgroups(struct intel_pinctrl *pctrl,
if (gpps[i].size > 32) if (gpps[i].size > 32)
return -EINVAL; return -EINVAL;
if (!gpps[i].gpio_base) /* Special treatment for GPIO base */
switch (gpps[i].gpio_base) {
case INTEL_GPIO_BASE_MATCH:
gpps[i].gpio_base = gpps[i].base; gpps[i].gpio_base = gpps[i].base;
break;
case INTEL_GPIO_BASE_NOMAP:
default:
break;
}
gpps[i].padown_num = padown_num; gpps[i].padown_num = padown_num;
...@@ -1596,7 +1603,7 @@ static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c, ...@@ -1596,7 +1603,7 @@ static void intel_restore_hostown(struct intel_pinctrl *pctrl, unsigned int c,
struct device *dev = pctrl->dev; struct device *dev = pctrl->dev;
u32 requested; u32 requested;
if (padgrp->gpio_base < 0) if (padgrp->gpio_base == INTEL_GPIO_BASE_NOMAP)
return; return;
requested = intel_gpio_is_requested(&pctrl->chip, padgrp->gpio_base, padgrp->size); requested = intel_gpio_is_requested(&pctrl->chip, padgrp->gpio_base, padgrp->size);
......
...@@ -53,8 +53,7 @@ struct intel_function { ...@@ -53,8 +53,7 @@ struct intel_function {
* @reg_num: GPI_IS register number * @reg_num: GPI_IS register number
* @base: Starting pin of this group * @base: Starting pin of this group
* @size: Size of this group (maximum is 32). * @size: Size of this group (maximum is 32).
* @gpio_base: Starting GPIO base of this group (%0 if matches with @base, * @gpio_base: Starting GPIO base of this group
* and %-1 if no GPIO mapping should be created)
* @padown_num: PAD_OWN register number (assigned by the core driver) * @padown_num: PAD_OWN register number (assigned by the core driver)
* *
* If pad groups of a community are not the same size, use this structure * If pad groups of a community are not the same size, use this structure
...@@ -68,6 +67,17 @@ struct intel_padgroup { ...@@ -68,6 +67,17 @@ struct intel_padgroup {
unsigned int padown_num; unsigned int padown_num;
}; };
/**
* enum - Special treatment for GPIO base in pad group
*
* @INTEL_GPIO_BASE_NOMAP: no GPIO mapping should be created
* @INTEL_GPIO_BASE_MATCH: matches with starting pin number
*/
enum {
INTEL_GPIO_BASE_NOMAP = -1,
INTEL_GPIO_BASE_MATCH = 0,
};
/** /**
* struct intel_community - Intel pin community description * struct intel_community - Intel pin community description
* @barno: MMIO BAR number where registers for this community reside * @barno: MMIO BAR number where registers for this community reside
......
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