diff options
author | Barry Song <Baohua.Song@csr.com> | 2012-08-22 22:47:54 -0400 |
---|---|---|
committer | Barry Song <Barry.Song@csr.com> | 2012-09-05 02:48:10 -0400 |
commit | 056876f6c73406c06d530d16d020177f5ec4a0bd (patch) | |
tree | f2ccb5d676cc62e2a9ef7ea759b3abaebc8b85e2 | |
parent | 434e1c574cc304eaff630f4e92ed239f7886815f (diff) |
pinctrl: sirf: add DT-binding pinmux mapping support
This makes us possible to define pinmux mapping in board-specific DTS.
prima2.dtsi provides all possible (groups,functions) configuration, and
device in .dts select configurations from dtsi files.
Signed-off-by: Barry Song <Baohua.Song@csr.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | arch/arm/boot/dts/prima2-evb.dts | 37 | ||||
-rw-r--r-- | arch/arm/boot/dts/prima2.dtsi | 221 | ||||
-rw-r--r-- | arch/arm/mach-prima2/Makefile.boot | 2 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-sirf.c | 58 |
4 files changed, 315 insertions, 3 deletions
diff --git a/arch/arm/boot/dts/prima2-evb.dts b/arch/arm/boot/dts/prima2-evb.dts new file mode 100644 index 000000000000..57286b4e7b87 --- /dev/null +++ b/arch/arm/boot/dts/prima2-evb.dts | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * DTS file for CSR SiRFprimaII Evaluation Board | ||
3 | * | ||
4 | * Copyright (c) 2012 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
5 | * | ||
6 | * Licensed under GPLv2 or later. | ||
7 | */ | ||
8 | |||
9 | /dts-v1/; | ||
10 | |||
11 | /include/ "prima2.dtsi" | ||
12 | |||
13 | / { | ||
14 | model = "CSR SiRFprimaII Evaluation Board"; | ||
15 | compatible = "sirf,prima2", "sirf,prima2-cb"; | ||
16 | |||
17 | memory { | ||
18 | reg = <0x00000000 0x20000000>; | ||
19 | }; | ||
20 | |||
21 | axi { | ||
22 | peri-iobg { | ||
23 | uart@b0060000 { | ||
24 | pinctrl-names = "default"; | ||
25 | pinctrl-0 = <&uart1_pins_a>; | ||
26 | }; | ||
27 | spi@b00d0000 { | ||
28 | pinctrl-names = "default"; | ||
29 | pinctrl-0 = <&spi0_pins_a>; | ||
30 | }; | ||
31 | spi@b0170000 { | ||
32 | pinctrl-names = "default"; | ||
33 | pinctrl-0 = <&spi1_pins_a>; | ||
34 | }; | ||
35 | }; | ||
36 | }; | ||
37 | }; | ||
diff --git a/arch/arm/boot/dts/prima2.dtsi b/arch/arm/boot/dts/prima2.dtsi index 1b716aae64f7..055fca542120 100644 --- a/arch/arm/boot/dts/prima2.dtsi +++ b/arch/arm/boot/dts/prima2.dtsi | |||
@@ -277,14 +277,231 @@ | |||
277 | interrupts = <33>; | 277 | interrupts = <33>; |
278 | }; | 278 | }; |
279 | 279 | ||
280 | gpio: gpio-controller@b0120000 { | 280 | gpio: pinctrl@b0120000 { |
281 | #gpio-cells = <2>; | 281 | #gpio-cells = <2>; |
282 | #interrupt-cells = <2>; | 282 | #interrupt-cells = <2>; |
283 | compatible = "sirf,prima2-gpio-pinmux"; | 283 | compatible = "sirf,prima2-pinctrl"; |
284 | reg = <0xb0120000 0x10000>; | 284 | reg = <0xb0120000 0x10000>; |
285 | interrupts = <43 44 45 46 47>; | 285 | interrupts = <43 44 45 46 47>; |
286 | gpio-controller; | 286 | gpio-controller; |
287 | interrupt-controller; | 287 | interrupt-controller; |
288 | |||
289 | lcd_16pins_a: lcd0@0 { | ||
290 | lcd { | ||
291 | sirf,pins = "lcd_16bitsgrp"; | ||
292 | sirf,function = "lcd_16bits"; | ||
293 | }; | ||
294 | }; | ||
295 | lcd_18pins_a: lcd0@1 { | ||
296 | lcd { | ||
297 | sirf,pins = "lcd_18bitsgrp"; | ||
298 | sirf,function = "lcd_18bits"; | ||
299 | }; | ||
300 | }; | ||
301 | lcd_24pins_a: lcd0@2 { | ||
302 | lcd { | ||
303 | sirf,pins = "lcd_24bitsgrp"; | ||
304 | sirf,function = "lcd_24bits"; | ||
305 | }; | ||
306 | }; | ||
307 | lcdrom_pins_a: lcdrom0@0 { | ||
308 | lcd { | ||
309 | sirf,pins = "lcdromgrp"; | ||
310 | sirf,function = "lcdrom"; | ||
311 | }; | ||
312 | }; | ||
313 | uart0_pins_a: uart0@0 { | ||
314 | uart { | ||
315 | sirf,pins = "uart0grp"; | ||
316 | sirf,function = "uart0"; | ||
317 | }; | ||
318 | }; | ||
319 | uart1_pins_a: uart1@0 { | ||
320 | uart { | ||
321 | sirf,pins = "uart1grp"; | ||
322 | sirf,function = "uart1"; | ||
323 | }; | ||
324 | }; | ||
325 | uart2_pins_a: uart2@0 { | ||
326 | uart { | ||
327 | sirf,pins = "uart2grp"; | ||
328 | sirf,function = "uart2"; | ||
329 | }; | ||
330 | }; | ||
331 | uart2_noflow_pins_a: uart2@1 { | ||
332 | uart { | ||
333 | sirf,pins = "uart2_nostreamctrlgrp"; | ||
334 | sirf,function = "uart2_nostreamctrl"; | ||
335 | }; | ||
336 | }; | ||
337 | spi0_pins_a: spi0@0 { | ||
338 | spi { | ||
339 | sirf,pins = "spi0grp"; | ||
340 | sirf,function = "spi0"; | ||
341 | }; | ||
342 | }; | ||
343 | spi1_pins_a: spi1@0 { | ||
344 | spi { | ||
345 | sirf,pins = "spi1grp"; | ||
346 | sirf,function = "spi1"; | ||
347 | }; | ||
348 | }; | ||
349 | i2c0_pins_a: i2c0@0 { | ||
350 | i2c { | ||
351 | sirf,pins = "i2c0grp"; | ||
352 | sirf,function = "i2c0"; | ||
353 | }; | ||
354 | }; | ||
355 | i2c1_pins_a: i2c1@0 { | ||
356 | i2c { | ||
357 | sirf,pins = "i2c1grp"; | ||
358 | sirf,function = "i2c1"; | ||
359 | }; | ||
360 | }; | ||
361 | pwm0_pins_a: pwm0@0 { | ||
362 | pwm { | ||
363 | sirf,pins = "pwm0grp"; | ||
364 | sirf,function = "pwm0"; | ||
365 | }; | ||
366 | }; | ||
367 | pwm1_pins_a: pwm1@0 { | ||
368 | pwm { | ||
369 | sirf,pins = "pwm1grp"; | ||
370 | sirf,function = "pwm1"; | ||
371 | }; | ||
372 | }; | ||
373 | pwm2_pins_a: pwm2@0 { | ||
374 | pwm { | ||
375 | sirf,pins = "pwm2grp"; | ||
376 | sirf,function = "pwm2"; | ||
377 | }; | ||
378 | }; | ||
379 | pwm3_pins_a: pwm3@0 { | ||
380 | pwm { | ||
381 | sirf,pins = "pwm3grp"; | ||
382 | sirf,function = "pwm3"; | ||
383 | }; | ||
384 | }; | ||
385 | gps_pins_a: gps@0 { | ||
386 | gps { | ||
387 | sirf,pins = "gpsgrp"; | ||
388 | sirf,function = "gps"; | ||
389 | }; | ||
390 | }; | ||
391 | vip_pins_a: vip@0 { | ||
392 | vip { | ||
393 | sirf,pins = "vipgrp"; | ||
394 | sirf,function = "vip"; | ||
395 | }; | ||
396 | }; | ||
397 | sdmmc0_pins_a: sdmmc0@0 { | ||
398 | sdmmc0 { | ||
399 | sirf,pins = "sdmmc0grp"; | ||
400 | sirf,function = "sdmmc0"; | ||
401 | }; | ||
402 | }; | ||
403 | sdmmc1_pins_a: sdmmc1@0 { | ||
404 | sdmmc1 { | ||
405 | sirf,pins = "sdmmc1grp"; | ||
406 | sirf,function = "sdmmc1"; | ||
407 | }; | ||
408 | }; | ||
409 | sdmmc2_pins_a: sdmmc2@0 { | ||
410 | sdmmc2 { | ||
411 | sirf,pins = "sdmmc2grp"; | ||
412 | sirf,function = "sdmmc2"; | ||
413 | }; | ||
414 | }; | ||
415 | sdmmc3_pins_a: sdmmc3@0 { | ||
416 | sdmmc3 { | ||
417 | sirf,pins = "sdmmc3grp"; | ||
418 | sirf,function = "sdmmc3"; | ||
419 | }; | ||
420 | }; | ||
421 | sdmmc4_pins_a: sdmmc4@0 { | ||
422 | sdmmc4 { | ||
423 | sirf,pins = "sdmmc4grp"; | ||
424 | sirf,function = "sdmmc4"; | ||
425 | }; | ||
426 | }; | ||
427 | sdmmc5_pins_a: sdmmc5@0 { | ||
428 | sdmmc5 { | ||
429 | sirf,pins = "sdmmc5grp"; | ||
430 | sirf,function = "sdmmc5"; | ||
431 | }; | ||
432 | }; | ||
433 | i2s_pins_a: i2s@0 { | ||
434 | i2s { | ||
435 | sirf,pins = "i2sgrp"; | ||
436 | sirf,function = "i2s"; | ||
437 | }; | ||
438 | }; | ||
439 | ac97_pins_a: ac97@0 { | ||
440 | ac97 { | ||
441 | sirf,pins = "ac97grp"; | ||
442 | sirf,function = "ac97"; | ||
443 | }; | ||
444 | }; | ||
445 | nand_pins_a: nand@0 { | ||
446 | nand { | ||
447 | sirf,pins = "nandgrp"; | ||
448 | sirf,function = "nand"; | ||
449 | }; | ||
450 | }; | ||
451 | usp0_pins_a: usp0@0 { | ||
452 | usp0 { | ||
453 | sirf,pins = "usp0grp"; | ||
454 | sirf,function = "usp0"; | ||
455 | }; | ||
456 | }; | ||
457 | usp1_pins_a: usp1@0 { | ||
458 | usp1 { | ||
459 | sirf,pins = "usp1grp"; | ||
460 | sirf,function = "usp1"; | ||
461 | }; | ||
462 | }; | ||
463 | usp2_pins_a: usp2@0 { | ||
464 | usp2 { | ||
465 | sirf,pins = "usp2grp"; | ||
466 | sirf,function = "usp2"; | ||
467 | }; | ||
468 | }; | ||
469 | usb0_utmi_drvbus_pins_a: usb0_utmi_drvbus@0 { | ||
470 | usb0_utmi_drvbus { | ||
471 | sirf,pins = "usb0_utmi_drvbusgrp"; | ||
472 | sirf,function = "usb0_utmi_drvbus"; | ||
473 | }; | ||
474 | }; | ||
475 | usb1_utmi_drvbus_pins_a: usb1_utmi_drvbus@0 { | ||
476 | usb1_utmi_drvbus { | ||
477 | sirf,pins = "usb1_utmi_drvbusgrp"; | ||
478 | sirf,function = "usb1_utmi_drvbus"; | ||
479 | }; | ||
480 | }; | ||
481 | warm_rst_pins_a: warm_rst@0 { | ||
482 | warm_rst { | ||
483 | sirf,pins = "warm_rstgrp"; | ||
484 | sirf,function = "warm_rst"; | ||
485 | }; | ||
486 | }; | ||
487 | pulse_count_pins_a: pulse_count@0 { | ||
488 | pulse_count { | ||
489 | sirf,pins = "pulse_countgrp"; | ||
490 | sirf,function = "pulse_count"; | ||
491 | }; | ||
492 | }; | ||
493 | cko0_rst_pins_a: cko0_rst@0 { | ||
494 | cko0_rst { | ||
495 | sirf,pins = "cko0_rstgrp"; | ||
496 | sirf,function = "cko0_rst"; | ||
497 | }; | ||
498 | }; | ||
499 | cko1_rst_pins_a: cko1_rst@0 { | ||
500 | cko1_rst { | ||
501 | sirf,pins = "cko1_rstgrp"; | ||
502 | sirf,function = "cko1_rst"; | ||
503 | }; | ||
504 | }; | ||
288 | }; | 505 | }; |
289 | 506 | ||
290 | pwm@b0130000 { | 507 | pwm@b0130000 { |
diff --git a/arch/arm/mach-prima2/Makefile.boot b/arch/arm/mach-prima2/Makefile.boot index c77a4883a4ee..98167da874c9 100644 --- a/arch/arm/mach-prima2/Makefile.boot +++ b/arch/arm/mach-prima2/Makefile.boot | |||
@@ -1,3 +1,5 @@ | |||
1 | zreladdr-y += 0x00008000 | 1 | zreladdr-y += 0x00008000 |
2 | params_phys-y := 0x00000100 | 2 | params_phys-y := 0x00000100 |
3 | initrd_phys-y := 0x00800000 | 3 | initrd_phys-y := 0x00800000 |
4 | |||
5 | dtb-$(CONFIG_ARCH_PRIMA2) += prima2-evb.dtb | ||
diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c index 7fca6ce5952b..304360cd213e 100644 --- a/drivers/pinctrl/pinctrl-sirf.c +++ b/drivers/pinctrl/pinctrl-sirf.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/pinctrl/pinctrl.h> | 17 | #include <linux/pinctrl/pinctrl.h> |
18 | #include <linux/pinctrl/pinmux.h> | 18 | #include <linux/pinctrl/pinmux.h> |
19 | #include <linux/pinctrl/consumer.h> | 19 | #include <linux/pinctrl/consumer.h> |
20 | #include <linux/pinctrl/machine.h> | ||
20 | #include <linux/of.h> | 21 | #include <linux/of.h> |
21 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
22 | #include <linux/of_device.h> | 23 | #include <linux/of_device.h> |
@@ -916,11 +917,66 @@ static void sirfsoc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s | |||
916 | seq_printf(s, " " DRIVER_NAME); | 917 | seq_printf(s, " " DRIVER_NAME); |
917 | } | 918 | } |
918 | 919 | ||
920 | static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev, | ||
921 | struct device_node *np_config, | ||
922 | struct pinctrl_map **map, unsigned *num_maps) | ||
923 | { | ||
924 | struct sirfsoc_pmx *spmx = pinctrl_dev_get_drvdata(pctldev); | ||
925 | struct device_node *np; | ||
926 | struct property *prop; | ||
927 | const char *function, *group; | ||
928 | int ret, index = 0, count = 0; | ||
929 | |||
930 | /* calculate number of maps required */ | ||
931 | for_each_child_of_node(np_config, np) { | ||
932 | ret = of_property_read_string(np, "sirf,function", &function); | ||
933 | if (ret < 0) | ||
934 | return ret; | ||
935 | |||
936 | ret = of_property_count_strings(np, "sirf,pins"); | ||
937 | if (ret < 0) | ||
938 | return ret; | ||
939 | |||
940 | count += ret; | ||
941 | } | ||
942 | |||
943 | if (!count) { | ||
944 | dev_err(spmx->dev, "No child nodes passed via DT\n"); | ||
945 | return -ENODEV; | ||
946 | } | ||
947 | |||
948 | *map = kzalloc(sizeof(**map) * count, GFP_KERNEL); | ||
949 | if (!*map) | ||
950 | return -ENOMEM; | ||
951 | |||
952 | for_each_child_of_node(np_config, np) { | ||
953 | of_property_read_string(np, "sirf,function", &function); | ||
954 | of_property_for_each_string(np, "sirf,pins", prop, group) { | ||
955 | (*map)[index].type = PIN_MAP_TYPE_MUX_GROUP; | ||
956 | (*map)[index].data.mux.group = group; | ||
957 | (*map)[index].data.mux.function = function; | ||
958 | index++; | ||
959 | } | ||
960 | } | ||
961 | |||
962 | *num_maps = count; | ||
963 | |||
964 | return 0; | ||
965 | } | ||
966 | |||
967 | static void sirfsoc_dt_free_map(struct pinctrl_dev *pctldev, | ||
968 | struct pinctrl_map *map, unsigned num_maps) | ||
969 | { | ||
970 | kfree(map); | ||
971 | } | ||
972 | |||
919 | static struct pinctrl_ops sirfsoc_pctrl_ops = { | 973 | static struct pinctrl_ops sirfsoc_pctrl_ops = { |
920 | .get_groups_count = sirfsoc_get_groups_count, | 974 | .get_groups_count = sirfsoc_get_groups_count, |
921 | .get_group_name = sirfsoc_get_group_name, | 975 | .get_group_name = sirfsoc_get_group_name, |
922 | .get_group_pins = sirfsoc_get_group_pins, | 976 | .get_group_pins = sirfsoc_get_group_pins, |
923 | .pin_dbg_show = sirfsoc_pin_dbg_show, | 977 | .pin_dbg_show = sirfsoc_pin_dbg_show, |
978 | .dt_node_to_map = sirfsoc_dt_node_to_map, | ||
979 | .dt_free_map = sirfsoc_dt_free_map, | ||
924 | }; | 980 | }; |
925 | 981 | ||
926 | struct sirfsoc_pmx_func { | 982 | struct sirfsoc_pmx_func { |
@@ -1221,7 +1277,7 @@ out_no_gpio_remap: | |||
1221 | } | 1277 | } |
1222 | 1278 | ||
1223 | static const struct of_device_id pinmux_ids[] __devinitconst = { | 1279 | static const struct of_device_id pinmux_ids[] __devinitconst = { |
1224 | { .compatible = "sirf,prima2-gpio-pinmux" }, | 1280 | { .compatible = "sirf,prima2-pinctrl" }, |
1225 | {} | 1281 | {} |
1226 | }; | 1282 | }; |
1227 | 1283 | ||