Commit 34e65670 authored by Andy Shevchenko's avatar Andy Shevchenko

pinctrl: baytrail: Re-use data structures from pinctrl-intel.h (part 2)

We have some data structures duplicated across the drivers.
Let's deduplicate them by using ones that being provided by
pinctrl-intel.h.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 179e5a61
...@@ -98,13 +98,6 @@ struct byt_gpio_pin_context { ...@@ -98,13 +98,6 @@ struct byt_gpio_pin_context {
u32 val; u32 val;
}; };
struct byt_community {
unsigned int pin_base;
size_t npins;
const unsigned int *pad_map;
void __iomem *reg_base;
};
#define COMMUNITY(p, n, map) \ #define COMMUNITY(p, n, map) \
{ \ { \
.pin_base = (p), \ .pin_base = (p), \
...@@ -112,26 +105,14 @@ struct byt_community { ...@@ -112,26 +105,14 @@ struct byt_community {
.pad_map = (map),\ .pad_map = (map),\
} }
struct byt_pinctrl_soc_data {
const char *uid;
const struct pinctrl_pin_desc *pins;
size_t npins;
const struct intel_pingroup *groups;
size_t ngroups;
const struct intel_function *functions;
size_t nfunctions;
const struct byt_community *communities;
size_t ncommunities;
};
struct byt_gpio { struct byt_gpio {
struct gpio_chip chip; struct gpio_chip chip;
struct platform_device *pdev; struct platform_device *pdev;
struct pinctrl_dev *pctl_dev; struct pinctrl_dev *pctl_dev;
struct pinctrl_desc pctl_desc; struct pinctrl_desc pctl_desc;
raw_spinlock_t lock; raw_spinlock_t lock;
const struct byt_pinctrl_soc_data *soc_data; const struct intel_pinctrl_soc_data *soc_data;
struct byt_community *communities_copy; struct intel_community *communities_copy;
struct byt_gpio_pin_context *saved_context; struct byt_gpio_pin_context *saved_context;
}; };
...@@ -383,11 +364,11 @@ static const struct intel_function byt_score_functions[] = { ...@@ -383,11 +364,11 @@ static const struct intel_function byt_score_functions[] = {
FUNCTION("gpio", byt_score_gpio_groups), FUNCTION("gpio", byt_score_gpio_groups),
}; };
static const struct byt_community byt_score_communities[] = { static const struct intel_community byt_score_communities[] = {
COMMUNITY(0, BYT_NGPIO_SCORE, byt_score_pins_map), COMMUNITY(0, BYT_NGPIO_SCORE, byt_score_pins_map),
}; };
static const struct byt_pinctrl_soc_data byt_score_soc_data = { static const struct intel_pinctrl_soc_data byt_score_soc_data = {
.uid = BYT_SCORE_ACPI_UID, .uid = BYT_SCORE_ACPI_UID,
.pins = byt_score_pins, .pins = byt_score_pins,
.npins = ARRAY_SIZE(byt_score_pins), .npins = ARRAY_SIZE(byt_score_pins),
...@@ -496,11 +477,11 @@ static const struct intel_function byt_sus_functions[] = { ...@@ -496,11 +477,11 @@ static const struct intel_function byt_sus_functions[] = {
FUNCTION("gpio", byt_sus_gpio_groups), FUNCTION("gpio", byt_sus_gpio_groups),
}; };
static const struct byt_community byt_sus_communities[] = { static const struct intel_community byt_sus_communities[] = {
COMMUNITY(0, BYT_NGPIO_SUS, byt_sus_pins_map), COMMUNITY(0, BYT_NGPIO_SUS, byt_sus_pins_map),
}; };
static const struct byt_pinctrl_soc_data byt_sus_soc_data = { static const struct intel_pinctrl_soc_data byt_sus_soc_data = {
.uid = BYT_SUS_ACPI_UID, .uid = BYT_SUS_ACPI_UID,
.pins = byt_sus_pins, .pins = byt_sus_pins,
.npins = ARRAY_SIZE(byt_sus_pins), .npins = ARRAY_SIZE(byt_sus_pins),
...@@ -549,11 +530,11 @@ static const unsigned int byt_ncore_pins_map[BYT_NGPIO_NCORE] = { ...@@ -549,11 +530,11 @@ static const unsigned int byt_ncore_pins_map[BYT_NGPIO_NCORE] = {
3, 6, 10, 13, 2, 5, 9, 7, 3, 6, 10, 13, 2, 5, 9, 7,
}; };
static const struct byt_community byt_ncore_communities[] = { static const struct intel_community byt_ncore_communities[] = {
COMMUNITY(0, BYT_NGPIO_NCORE, byt_ncore_pins_map), COMMUNITY(0, BYT_NGPIO_NCORE, byt_ncore_pins_map),
}; };
static const struct byt_pinctrl_soc_data byt_ncore_soc_data = { static const struct intel_pinctrl_soc_data byt_ncore_soc_data = {
.uid = BYT_NCORE_ACPI_UID, .uid = BYT_NCORE_ACPI_UID,
.pins = byt_ncore_pins, .pins = byt_ncore_pins,
.npins = ARRAY_SIZE(byt_ncore_pins), .npins = ARRAY_SIZE(byt_ncore_pins),
...@@ -561,17 +542,17 @@ static const struct byt_pinctrl_soc_data byt_ncore_soc_data = { ...@@ -561,17 +542,17 @@ static const struct byt_pinctrl_soc_data byt_ncore_soc_data = {
.ncommunities = ARRAY_SIZE(byt_ncore_communities), .ncommunities = ARRAY_SIZE(byt_ncore_communities),
}; };
static const struct byt_pinctrl_soc_data *byt_soc_data[] = { static const struct intel_pinctrl_soc_data *byt_soc_data[] = {
&byt_score_soc_data, &byt_score_soc_data,
&byt_sus_soc_data, &byt_sus_soc_data,
&byt_ncore_soc_data, &byt_ncore_soc_data,
NULL NULL
}; };
static struct byt_community *byt_get_community(struct byt_gpio *vg, static struct intel_community *byt_get_community(struct byt_gpio *vg,
unsigned int pin) unsigned int pin)
{ {
struct byt_community *comm; struct intel_community *comm;
int i; int i;
for (i = 0; i < vg->soc_data->ncommunities; i++) { for (i = 0; i < vg->soc_data->ncommunities; i++) {
...@@ -586,7 +567,7 @@ static struct byt_community *byt_get_community(struct byt_gpio *vg, ...@@ -586,7 +567,7 @@ static struct byt_community *byt_get_community(struct byt_gpio *vg,
static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset,
int reg) int reg)
{ {
struct byt_community *comm = byt_get_community(vg, offset); struct intel_community *comm = byt_get_community(vg, offset);
u32 reg_offset; u32 reg_offset;
if (!comm) if (!comm)
...@@ -605,7 +586,7 @@ static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset, ...@@ -605,7 +586,7 @@ static void __iomem *byt_gpio_reg(struct byt_gpio *vg, unsigned int offset,
break; break;
} }
return comm->reg_base + reg_offset + reg; return comm->pad_regs + reg_offset + reg;
} }
static int byt_get_groups_count(struct pinctrl_dev *pctldev) static int byt_get_groups_count(struct pinctrl_dev *pctldev)
...@@ -1211,7 +1192,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) ...@@ -1211,7 +1192,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
u32 conf0, val; u32 conf0, val;
for (i = 0; i < vg->soc_data->npins; i++) { for (i = 0; i < vg->soc_data->npins; i++) {
const struct byt_community *comm; const struct intel_community *comm;
const char *pull_str = NULL; const char *pull_str = NULL;
const char *pull = NULL; const char *pull = NULL;
void __iomem *reg; void __iomem *reg;
...@@ -1566,7 +1547,7 @@ static int byt_gpio_probe(struct byt_gpio *vg) ...@@ -1566,7 +1547,7 @@ static int byt_gpio_probe(struct byt_gpio *vg)
} }
static int byt_set_soc_data(struct byt_gpio *vg, static int byt_set_soc_data(struct byt_gpio *vg,
const struct byt_pinctrl_soc_data *soc_data) const struct intel_pinctrl_soc_data *soc_data)
{ {
int i; int i;
...@@ -1579,13 +1560,13 @@ static int byt_set_soc_data(struct byt_gpio *vg, ...@@ -1579,13 +1560,13 @@ static int byt_set_soc_data(struct byt_gpio *vg,
return -ENOMEM; return -ENOMEM;
for (i = 0; i < soc_data->ncommunities; i++) { for (i = 0; i < soc_data->ncommunities; i++) {
struct byt_community *comm = vg->communities_copy + i; struct intel_community *comm = vg->communities_copy + i;
*comm = vg->soc_data->communities[i]; *comm = vg->soc_data->communities[i];
comm->reg_base = devm_platform_ioremap_resource(vg->pdev, 0); comm->pad_regs = devm_platform_ioremap_resource(vg->pdev, 0);
if (IS_ERR(comm->reg_base)) if (IS_ERR(comm->pad_regs))
return PTR_ERR(comm->reg_base); return PTR_ERR(comm->pad_regs);
} }
return 0; return 0;
...@@ -1599,8 +1580,8 @@ static const struct acpi_device_id byt_gpio_acpi_match[] = { ...@@ -1599,8 +1580,8 @@ static const struct acpi_device_id byt_gpio_acpi_match[] = {
static int byt_pinctrl_probe(struct platform_device *pdev) static int byt_pinctrl_probe(struct platform_device *pdev)
{ {
const struct byt_pinctrl_soc_data *soc_data = NULL; const struct intel_pinctrl_soc_data *soc_data = NULL;
const struct byt_pinctrl_soc_data **soc_table; const struct intel_pinctrl_soc_data **soc_table;
struct acpi_device *acpi_dev; struct acpi_device *acpi_dev;
struct byt_gpio *vg; struct byt_gpio *vg;
int i, ret; int i, ret;
...@@ -1609,7 +1590,7 @@ static int byt_pinctrl_probe(struct platform_device *pdev) ...@@ -1609,7 +1590,7 @@ static int byt_pinctrl_probe(struct platform_device *pdev)
if (!acpi_dev) if (!acpi_dev)
return -ENODEV; return -ENODEV;
soc_table = (const struct byt_pinctrl_soc_data **)device_get_match_data(&pdev->dev); soc_table = (const struct intel_pinctrl_soc_data **)device_get_match_data(&pdev->dev);
for (i = 0; soc_table[i]; i++) { for (i = 0; soc_table[i]; i++) {
if (!strcmp(acpi_dev->pnp.unique_id, soc_table[i]->uid)) { if (!strcmp(acpi_dev->pnp.unique_id, soc_table[i]->uid)) {
......
...@@ -77,6 +77,7 @@ struct intel_padgroup { ...@@ -77,6 +77,7 @@ struct intel_padgroup {
* ACPI). * ACPI).
* @is_offset: Register offset of GPI_IS from @regs. * @is_offset: Register offset of GPI_IS from @regs.
* @ie_offset: Register offset of GPI_IE from @regs. * @ie_offset: Register offset of GPI_IE from @regs.
* @features: Additional features supported by the hardware
* @pin_base: Starting pin of pins in this community * @pin_base: Starting pin of pins in this community
* @gpp_size: Maximum number of pads in each group, such as PADCFGLOCK, * @gpp_size: Maximum number of pads in each group, such as PADCFGLOCK,
* HOSTSW_OWN, GPI_IS, GPI_IE, etc. Used when @gpps is %NULL. * HOSTSW_OWN, GPI_IS, GPI_IE, etc. Used when @gpps is %NULL.
...@@ -84,9 +85,9 @@ struct intel_padgroup { ...@@ -84,9 +85,9 @@ struct intel_padgroup {
* minimum. Use %0 if the number of registers can be * minimum. Use %0 if the number of registers can be
* determined by the size of the group. * determined by the size of the group.
* @npins: Number of pins in this community * @npins: Number of pins in this community
* @features: Additional features supported by the hardware
* @gpps: Pad groups if the controller has variable size pad groups * @gpps: Pad groups if the controller has variable size pad groups
* @ngpps: Number of pad groups in this community * @ngpps: Number of pad groups in this community
* @pad_map: Optional non-linear mapping of the pads
* @regs: Community specific common registers (reserved for core driver) * @regs: Community specific common registers (reserved for core driver)
* @pad_regs: Community specific pad registers (reserved for core driver) * @pad_regs: Community specific pad registers (reserved for core driver)
* *
...@@ -103,13 +104,14 @@ struct intel_community { ...@@ -103,13 +104,14 @@ struct intel_community {
unsigned int hostown_offset; unsigned int hostown_offset;
unsigned int is_offset; unsigned int is_offset;
unsigned int ie_offset; unsigned int ie_offset;
unsigned int features;
unsigned int pin_base; unsigned int pin_base;
unsigned int gpp_size; unsigned int gpp_size;
unsigned int gpp_num_padown_regs; unsigned int gpp_num_padown_regs;
size_t npins; size_t npins;
unsigned int features;
const struct intel_padgroup *gpps; const struct intel_padgroup *gpps;
size_t ngpps; size_t ngpps;
const unsigned int *pad_map;
/* Reserved for the core driver */ /* Reserved for the core driver */
void __iomem *regs; void __iomem *regs;
void __iomem *pad_regs; void __iomem *pad_regs;
......
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