diff options
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra186-dpaux.c | 201 |
1 files changed, 168 insertions, 33 deletions
diff --git a/drivers/pinctrl/pinctrl-tegra186-dpaux.c b/drivers/pinctrl/pinctrl-tegra186-dpaux.c index 655638b49..4a69d3f41 100644 --- a/drivers/pinctrl/pinctrl-tegra186-dpaux.c +++ b/drivers/pinctrl/pinctrl-tegra186-dpaux.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. | 2 | * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. |
3 | * | 3 | * |
4 | * Author: Suresh Mangipudi <smangipudi@nvidia.com> | 4 | * Author: Suresh Mangipudi <smangipudi@nvidia.com> |
5 | * | 5 | * |
@@ -47,11 +47,18 @@ | |||
47 | .kernel_only = true, \ | 47 | .kernel_only = true, \ |
48 | } | 48 | } |
49 | 49 | ||
50 | static struct nvhost_device_data tegra_dpaux_nvhost_device_data[] = { | 50 | static struct nvhost_device_data tegra186_dpaux_nvhost_device_data[] = { |
51 | DPAUX_NVHOST_DEVICE_DATA(dpaux), | 51 | DPAUX_NVHOST_DEVICE_DATA(dpaux), |
52 | DPAUX_NVHOST_DEVICE_DATA(dpaux1), | 52 | DPAUX_NVHOST_DEVICE_DATA(dpaux1), |
53 | }; | 53 | }; |
54 | 54 | ||
55 | static struct nvhost_device_data tegra194_dpaux_nvhost_device_data[] = { | ||
56 | DPAUX_NVHOST_DEVICE_DATA(dpaux), | ||
57 | DPAUX_NVHOST_DEVICE_DATA(dpaux1), | ||
58 | DPAUX_NVHOST_DEVICE_DATA(dpaux2), | ||
59 | DPAUX_NVHOST_DEVICE_DATA(dpaux3), | ||
60 | }; | ||
61 | |||
55 | struct tegra_dpaux_function { | 62 | struct tegra_dpaux_function { |
56 | const char *name; | 63 | const char *name; |
57 | const char * const *groups; | 64 | const char * const *groups; |
@@ -81,12 +88,31 @@ struct tegra_dpaux_pinctl { | |||
81 | unsigned ngroups; | 88 | unsigned ngroups; |
82 | }; | 89 | }; |
83 | 90 | ||
91 | struct tegra_dpaux_chip_data { | ||
92 | struct nvhost_device_data *nvhost_data; | ||
93 | const struct pinctrl_pin_desc *pins; | ||
94 | u32 npins; | ||
95 | const struct tegra_dpaux_pingroup *pin_group; | ||
96 | u32 npin_groups; | ||
97 | struct tegra_dpaux_function *functions; | ||
98 | u32 nfunctions; | ||
99 | }; | ||
100 | |||
84 | #define TEGRA_PIN_DPAUX_0 0 | 101 | #define TEGRA_PIN_DPAUX_0 0 |
85 | #define TEGRA_PIN_DPAUX1_1 1 | 102 | #define TEGRA_PIN_DPAUX1_1 1 |
103 | #define TEGRA_PIN_DPAUX2_2 2 | ||
104 | #define TEGRA_PIN_DPAUX3_3 3 | ||
105 | |||
106 | static const struct pinctrl_pin_desc tegra186_dpaux_pins[] = { | ||
107 | PINCTRL_PIN(TEGRA_PIN_DPAUX_0, "dpaux-0"), | ||
108 | PINCTRL_PIN(TEGRA_PIN_DPAUX1_1, "dpaux1-1"), | ||
109 | }; | ||
86 | 110 | ||
87 | static const struct pinctrl_pin_desc tegra_dpaux_pins[] = { | 111 | static const struct pinctrl_pin_desc tegra194_dpaux_pins[] = { |
88 | PINCTRL_PIN(TEGRA_PIN_DPAUX_0, "dpaux-0"), | 112 | PINCTRL_PIN(TEGRA_PIN_DPAUX_0, "dpaux-0"), |
89 | PINCTRL_PIN(TEGRA_PIN_DPAUX1_1, "dpaux1-1"), | 113 | PINCTRL_PIN(TEGRA_PIN_DPAUX1_1, "dpaux1-1"), |
114 | PINCTRL_PIN(TEGRA_PIN_DPAUX2_2, "dpaux2-2"), | ||
115 | PINCTRL_PIN(TEGRA_PIN_DPAUX3_3, "dpaux3-3"), | ||
90 | }; | 116 | }; |
91 | 117 | ||
92 | enum tegra_dpaux_mux { | 118 | enum tegra_dpaux_mux { |
@@ -94,22 +120,33 @@ enum tegra_dpaux_mux { | |||
94 | TEGRA_DPAUX_MUX_DISPLAY, | 120 | TEGRA_DPAUX_MUX_DISPLAY, |
95 | }; | 121 | }; |
96 | 122 | ||
97 | #define PIN_NAMES "dpaux-0", "dpaux1-1" | 123 | #define TEGRA186_PIN_NAMES "dpaux-0", "dpaux1-1" |
98 | 124 | ||
99 | static const char * const dpaux_pin_groups[] = { | 125 | static const char * const tegra186_dpaux_pin_groups[] = { |
100 | PIN_NAMES | 126 | TEGRA186_PIN_NAMES |
101 | }; | 127 | }; |
102 | 128 | ||
103 | #define FUNCTION(fname) \ | 129 | #define TEGRA194_PIN_NAMES "dpaux-0", "dpaux1-1", "dpaux2-2", "dpaux3-3" |
104 | { \ | 130 | |
105 | .name = #fname, \ | 131 | static const char * const tegra194_dpaux_pin_groups[] = { |
106 | .groups = dpaux_pin_groups, \ | 132 | TEGRA194_PIN_NAMES |
107 | .ngroups = ARRAY_SIZE(dpaux_pin_groups),\ | 133 | }; |
108 | } \ | 134 | |
109 | 135 | #define FUNCTION(fname, group) \ | |
110 | static struct tegra_dpaux_function tegra_dpaux_functions[] = { | 136 | { \ |
111 | FUNCTION(i2c), | 137 | .name = #fname, \ |
112 | FUNCTION(display), | 138 | .groups = group, \ |
139 | .ngroups = ARRAY_SIZE(group), \ | ||
140 | } \ | ||
141 | |||
142 | static struct tegra_dpaux_function tegra186_dpaux_functions[] = { | ||
143 | FUNCTION(i2c, tegra186_dpaux_pin_groups), | ||
144 | FUNCTION(display, tegra186_dpaux_pin_groups), | ||
145 | }; | ||
146 | |||
147 | static struct tegra_dpaux_function tegra194_dpaux_functions[] = { | ||
148 | FUNCTION(i2c, tegra194_dpaux_pin_groups), | ||
149 | FUNCTION(display, tegra194_dpaux_pin_groups), | ||
113 | }; | 150 | }; |
114 | 151 | ||
115 | #define PINGROUP(pg_name, pin_id, f0, f1) \ | 152 | #define PINGROUP(pg_name, pin_id, f0, f1) \ |
@@ -123,11 +160,78 @@ static struct tegra_dpaux_function tegra_dpaux_functions[] = { | |||
123 | }, \ | 160 | }, \ |
124 | } | 161 | } |
125 | 162 | ||
126 | static const struct tegra_dpaux_pingroup tegra_dpaux_groups[] = { | 163 | static const struct tegra_dpaux_pingroup tegra186_dpaux_groups[] = { |
127 | PINGROUP(dpaux_0, DPAUX_0, I2C, DISPLAY), | 164 | PINGROUP(dpaux_0, DPAUX_0, I2C, DISPLAY), |
128 | PINGROUP(dpaux1_1, DPAUX1_1, I2C, DISPLAY), | 165 | PINGROUP(dpaux1_1, DPAUX1_1, I2C, DISPLAY), |
129 | }; | 166 | }; |
130 | 167 | ||
168 | static const struct tegra_dpaux_pingroup tegra194_dpaux_groups[] = { | ||
169 | PINGROUP(dpaux_0, DPAUX_0, I2C, DISPLAY), | ||
170 | PINGROUP(dpaux1_1, DPAUX1_1, I2C, DISPLAY), | ||
171 | PINGROUP(dpaux2_2, DPAUX2_2, I2C, DISPLAY), | ||
172 | PINGROUP(dpaux3_3, DPAUX3_3, I2C, DISPLAY), | ||
173 | }; | ||
174 | |||
175 | static struct tegra_dpaux_chip_data tegra186_dpaux_chip_data[] = { | ||
176 | { | ||
177 | .nvhost_data = &tegra186_dpaux_nvhost_device_data[0], | ||
178 | .pins = tegra186_dpaux_pins, | ||
179 | .npins = ARRAY_SIZE(tegra186_dpaux_pins), | ||
180 | .pin_group = tegra186_dpaux_groups, | ||
181 | .npin_groups = ARRAY_SIZE(tegra186_dpaux_groups), | ||
182 | .functions = tegra186_dpaux_functions, | ||
183 | .nfunctions = ARRAY_SIZE(tegra186_dpaux_functions), | ||
184 | }, | ||
185 | { | ||
186 | .nvhost_data = &tegra186_dpaux_nvhost_device_data[1], | ||
187 | .pins = tegra186_dpaux_pins, | ||
188 | .npins = ARRAY_SIZE(tegra186_dpaux_pins), | ||
189 | .pin_group = tegra186_dpaux_groups, | ||
190 | .npin_groups = ARRAY_SIZE(tegra186_dpaux_groups), | ||
191 | .functions = tegra186_dpaux_functions, | ||
192 | .nfunctions = ARRAY_SIZE(tegra186_dpaux_functions), | ||
193 | }, | ||
194 | }; | ||
195 | |||
196 | static struct tegra_dpaux_chip_data tegra194_dpaux_chip_data[] = { | ||
197 | { | ||
198 | .nvhost_data = &tegra194_dpaux_nvhost_device_data[0], | ||
199 | .pins = tegra194_dpaux_pins, | ||
200 | .npins = ARRAY_SIZE(tegra194_dpaux_pins), | ||
201 | .pin_group = tegra194_dpaux_groups, | ||
202 | .npin_groups = ARRAY_SIZE(tegra194_dpaux_groups), | ||
203 | .functions = tegra194_dpaux_functions, | ||
204 | .nfunctions = ARRAY_SIZE(tegra194_dpaux_functions), | ||
205 | }, | ||
206 | { | ||
207 | .nvhost_data = &tegra194_dpaux_nvhost_device_data[1], | ||
208 | .pins = tegra194_dpaux_pins, | ||
209 | .npins = ARRAY_SIZE(tegra194_dpaux_pins), | ||
210 | .pin_group = tegra194_dpaux_groups, | ||
211 | .npin_groups = ARRAY_SIZE(tegra194_dpaux_groups), | ||
212 | .functions = tegra194_dpaux_functions, | ||
213 | .nfunctions = ARRAY_SIZE(tegra194_dpaux_functions), | ||
214 | }, | ||
215 | { | ||
216 | .nvhost_data = &tegra194_dpaux_nvhost_device_data[2], | ||
217 | .pins = tegra194_dpaux_pins, | ||
218 | .npins = ARRAY_SIZE(tegra194_dpaux_pins), | ||
219 | .pin_group = tegra194_dpaux_groups, | ||
220 | .npin_groups = ARRAY_SIZE(tegra194_dpaux_groups), | ||
221 | .functions = tegra194_dpaux_functions, | ||
222 | .nfunctions = ARRAY_SIZE(tegra194_dpaux_functions), | ||
223 | }, | ||
224 | { | ||
225 | .nvhost_data = &tegra194_dpaux_nvhost_device_data[3], | ||
226 | .pins = tegra194_dpaux_pins, | ||
227 | .npins = ARRAY_SIZE(tegra194_dpaux_pins), | ||
228 | .pin_group = tegra194_dpaux_groups, | ||
229 | .npin_groups = ARRAY_SIZE(tegra194_dpaux_groups), | ||
230 | .functions = tegra194_dpaux_functions, | ||
231 | .nfunctions = ARRAY_SIZE(tegra194_dpaux_functions), | ||
232 | }, | ||
233 | }; | ||
234 | |||
131 | static void tegra_dpaux_update(struct tegra_dpaux_pinctl *tdp_aux, | 235 | static void tegra_dpaux_update(struct tegra_dpaux_pinctl *tdp_aux, |
132 | u32 reg_offset, u32 mask, u32 val) | 236 | u32 reg_offset, u32 mask, u32 val) |
133 | { | 237 | { |
@@ -239,8 +343,9 @@ static const struct pinmux_ops tegra_dpaux_pinmux_ops = { | |||
239 | 343 | ||
240 | static int tegra186_dpaux_pinctrl_probe(struct platform_device *pdev) | 344 | static int tegra186_dpaux_pinctrl_probe(struct platform_device *pdev) |
241 | { | 345 | { |
242 | struct nvhost_device_data *nhd_data; | 346 | struct tegra_dpaux_chip_data *cdata; |
243 | struct tegra_dpaux_pinctl *tdpaux_ctl; | 347 | struct tegra_dpaux_pinctl *tdpaux_ctl; |
348 | struct nvhost_device_data *nhd_data; | ||
244 | int ret; | 349 | int ret; |
245 | 350 | ||
246 | tdpaux_ctl = devm_kzalloc(&pdev->dev, sizeof(*tdpaux_ctl), GFP_KERNEL); | 351 | tdpaux_ctl = devm_kzalloc(&pdev->dev, sizeof(*tdpaux_ctl), GFP_KERNEL); |
@@ -248,8 +353,9 @@ static int tegra186_dpaux_pinctrl_probe(struct platform_device *pdev) | |||
248 | return -ENOMEM; | 353 | return -ENOMEM; |
249 | 354 | ||
250 | tdpaux_ctl->dev = &pdev->dev; | 355 | tdpaux_ctl->dev = &pdev->dev; |
251 | nhd_data = (struct nvhost_device_data *) | 356 | cdata = (struct tegra_dpaux_chip_data *) |
252 | of_device_get_match_data(&pdev->dev); | 357 | of_device_get_match_data(&pdev->dev); |
358 | nhd_data = cdata->nvhost_data; | ||
253 | 359 | ||
254 | mutex_init(&nhd_data->lock); | 360 | mutex_init(&nhd_data->lock); |
255 | tdpaux_ctl->pdev = pdev; | 361 | tdpaux_ctl->pdev = pdev; |
@@ -276,12 +382,12 @@ static int tegra186_dpaux_pinctrl_probe(struct platform_device *pdev) | |||
276 | 382 | ||
277 | tdpaux_ctl->regs = nhd_data->aperture[0]; | 383 | tdpaux_ctl->regs = nhd_data->aperture[0]; |
278 | 384 | ||
279 | tdpaux_ctl->pins = tegra_dpaux_pins; | 385 | tdpaux_ctl->pins = cdata->pins; |
280 | tdpaux_ctl->npins = ARRAY_SIZE(tegra_dpaux_pins); | 386 | tdpaux_ctl->npins = cdata->npins; |
281 | tdpaux_ctl->functions = tegra_dpaux_functions; | 387 | tdpaux_ctl->functions = cdata->functions; |
282 | tdpaux_ctl->nfunctions = ARRAY_SIZE(tegra_dpaux_functions); | 388 | tdpaux_ctl->nfunctions = cdata->nfunctions; |
283 | tdpaux_ctl->groups = tegra_dpaux_groups; | 389 | tdpaux_ctl->groups = cdata->pin_group; |
284 | tdpaux_ctl->ngroups = ARRAY_SIZE(tegra_dpaux_groups); | 390 | tdpaux_ctl->ngroups = cdata->npin_groups; |
285 | 391 | ||
286 | memset(&tdpaux_ctl->desc, 0, sizeof(tdpaux_ctl->desc)); | 392 | memset(&tdpaux_ctl->desc, 0, sizeof(tdpaux_ctl->desc)); |
287 | tdpaux_ctl->desc.name = dev_name(&pdev->dev); | 393 | tdpaux_ctl->desc.name = dev_name(&pdev->dev); |
@@ -344,9 +450,17 @@ static int tegra186_dpaux_probe(struct platform_device *pdev) | |||
344 | 450 | ||
345 | static struct of_device_id tegra_dpaux_pinctl_of_match[] = { | 451 | static struct of_device_id tegra_dpaux_pinctl_of_match[] = { |
346 | {.compatible = "nvidia,tegra186-dpaux-padctl", | 452 | {.compatible = "nvidia,tegra186-dpaux-padctl", |
347 | .data = &tegra_dpaux_nvhost_device_data[0]}, | 453 | .data = &tegra186_dpaux_chip_data[0]}, |
348 | {.compatible = "nvidia,tegra186-dpaux1-padctl", | 454 | {.compatible = "nvidia,tegra186-dpaux1-padctl", |
349 | .data = &tegra_dpaux_nvhost_device_data[1]}, | 455 | .data = &tegra186_dpaux_chip_data[1]}, |
456 | {.compatible = "nvidia,tegra194-dpaux-padctl", | ||
457 | .data = &tegra194_dpaux_chip_data[0]}, | ||
458 | {.compatible = "nvidia,tegra194-dpaux1-padctl", | ||
459 | .data = &tegra194_dpaux_chip_data[1]}, | ||
460 | {.compatible = "nvidia,tegra194-dpaux2-padctl", | ||
461 | .data = &tegra194_dpaux_chip_data[2]}, | ||
462 | {.compatible = "nvidia,tegra194-dpaux3-padctl", | ||
463 | .data = &tegra194_dpaux_chip_data[3]}, | ||
350 | { } | 464 | { } |
351 | }; | 465 | }; |
352 | MODULE_DEVICE_TABLE(of, tegra_dpaux_pinctl_of_match); | 466 | MODULE_DEVICE_TABLE(of, tegra_dpaux_pinctl_of_match); |
@@ -360,20 +474,41 @@ static struct platform_driver tegra186_dpaux_pinctrl = { | |||
360 | .probe = tegra186_dpaux_pinctrl_probe, | 474 | .probe = tegra186_dpaux_pinctrl_probe, |
361 | }; | 475 | }; |
362 | 476 | ||
363 | static struct of_device_id nvdisp_disa_pd_match[] = { | 477 | static const struct of_device_id tegra186_nvdisp_disa_pd_match[] = { |
364 | { .compatible = "nvidia,tegra186-disa-pd", | 478 | { .compatible = "nvidia,tegra186-disa-pd", |
365 | .data = &tegra_dpaux_nvhost_device_data[0]}, | 479 | .data = &tegra186_dpaux_nvhost_device_data[0]}, |
366 | { .compatible = "nvidia,tegra186-disa-pd", | 480 | { .compatible = "nvidia,tegra186-disa-pd", |
367 | .data = &tegra_dpaux_nvhost_device_data[1]}, | 481 | .data = &tegra186_dpaux_nvhost_device_data[1]}, |
482 | {}, | ||
483 | }; | ||
484 | MODULE_DEVICE_TABLE(of, tegra186_nvdisp_disa_pd_match); | ||
485 | |||
486 | static const struct of_device_id tegra194_nvdisp_disa_pd_match[] = { | ||
487 | { .compatible = "nvidia,tegra194-disa-pd", | ||
488 | .data = &tegra194_dpaux_nvhost_device_data[0]}, | ||
489 | { .compatible = "nvidia,tegra194-disa-pd", | ||
490 | .data = &tegra194_dpaux_nvhost_device_data[1]}, | ||
491 | { .compatible = "nvidia,tegra194-disa-pd", | ||
492 | .data = &tegra194_dpaux_nvhost_device_data[2]}, | ||
493 | { .compatible = "nvidia,tegra194-disa-pd", | ||
494 | .data = &tegra194_dpaux_nvhost_device_data[3]}, | ||
368 | {}, | 495 | {}, |
369 | }; | 496 | }; |
370 | MODULE_DEVICE_TABLE(of, nvdisp_disa_pd_match); | 497 | MODULE_DEVICE_TABLE(of, tegra194_nvdisp_disa_pd_match); |
371 | 498 | ||
372 | static struct of_device_id tegra_dpaux_of_match[] = { | 499 | static struct of_device_id tegra_dpaux_of_match[] = { |
373 | {.compatible = "nvidia,tegra186-dpaux-pinctrl", | 500 | {.compatible = "nvidia,tegra186-dpaux-pinctrl", |
374 | .data = &nvdisp_disa_pd_match[0]}, | 501 | .data = &tegra186_nvdisp_disa_pd_match[0]}, |
375 | {.compatible = "nvidia,tegra186-dpaux1-pinctrl", | 502 | {.compatible = "nvidia,tegra186-dpaux1-pinctrl", |
376 | .data = &nvdisp_disa_pd_match[1]}, | 503 | .data = &tegra186_nvdisp_disa_pd_match[1]}, |
504 | {.compatible = "nvidia,tegra194-dpaux-pinctrl", | ||
505 | .data = &tegra194_nvdisp_disa_pd_match[0]}, | ||
506 | {.compatible = "nvidia,tegra194-dpaux1-pinctrl", | ||
507 | .data = &tegra194_nvdisp_disa_pd_match[1]}, | ||
508 | {.compatible = "nvidia,tegra194-dpaux2-pinctrl", | ||
509 | .data = &tegra194_nvdisp_disa_pd_match[2]}, | ||
510 | {.compatible = "nvidia,tegra194-dpaux3-pinctrl", | ||
511 | .data = &tegra194_nvdisp_disa_pd_match[3]}, | ||
377 | { } | 512 | { } |
378 | }; | 513 | }; |
379 | MODULE_DEVICE_TABLE(of, tegra_dpaux_of_match); | 514 | MODULE_DEVICE_TABLE(of, tegra_dpaux_of_match); |