diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-08-19 09:40:07 -0400 |
---|---|---|
committer | Kukjin Kim <kgene.kim@samsung.com> | 2011-09-19 03:32:36 -0400 |
commit | d0f0b43f78b88b42e795e4c28f3591cb57590692 (patch) | |
tree | 7ecd262fb0dc8df08c035b784dd3b3662fe390cd /arch/arm | |
parent | 986afc98ce24901865828dab9ba876fd9be6beb2 (diff) |
ARM: S3C64XX: Use module identification for Cragganmore system builds
The Cragganmore system is modular with I2C based identification chips on
the system allowing identification of the system build. Provide a stub I2C
driver which parses the module IDs and uses them to select the appropriate
audio subsystem components to register. To avoid confusion due to having
the mini-driver in the system the driver is placed in a separate file.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-s3c64xx/Kconfig | 1 | ||||
-rw-r--r-- | arch/arm/mach-s3c64xx/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-s3c64xx/include/mach/crag6410.h | 23 | ||||
-rw-r--r-- | arch/arm/mach-s3c64xx/mach-crag6410-module.c | 173 | ||||
-rw-r--r-- | arch/arm/mach-s3c64xx/mach-crag6410.c | 85 |
5 files changed, 203 insertions, 81 deletions
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig index f057b6ae4f90..5552e048c2be 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig | |||
@@ -288,5 +288,6 @@ config MACH_WLF_CRAGG_6410 | |||
288 | select S3C_DEV_RTC | 288 | select S3C_DEV_RTC |
289 | select S3C64XX_DEV_SPI | 289 | select S3C64XX_DEV_SPI |
290 | select S3C24XX_GPIO_EXTRA128 | 290 | select S3C24XX_GPIO_EXTRA128 |
291 | select I2C | ||
291 | help | 292 | help |
292 | Machine support for the Wolfson Cragganmore S3C6410 variant. | 293 | Machine support for the Wolfson Cragganmore S3C6410 variant. |
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile index 61b4034a0c22..5fdea6aa50d4 100644 --- a/arch/arm/mach-s3c64xx/Makefile +++ b/arch/arm/mach-s3c64xx/Makefile | |||
@@ -55,7 +55,7 @@ obj-$(CONFIG_MACH_HMT) += mach-hmt.o | |||
55 | obj-$(CONFIG_MACH_SMARTQ) += mach-smartq.o | 55 | obj-$(CONFIG_MACH_SMARTQ) += mach-smartq.o |
56 | obj-$(CONFIG_MACH_SMARTQ5) += mach-smartq5.o | 56 | obj-$(CONFIG_MACH_SMARTQ5) += mach-smartq5.o |
57 | obj-$(CONFIG_MACH_SMARTQ7) += mach-smartq7.o | 57 | obj-$(CONFIG_MACH_SMARTQ7) += mach-smartq7.o |
58 | obj-$(CONFIG_MACH_WLF_CRAGG_6410) += mach-crag6410.o | 58 | obj-$(CONFIG_MACH_WLF_CRAGG_6410) += mach-crag6410.o mach-crag6410-module.o |
59 | 59 | ||
60 | # device support | 60 | # device support |
61 | 61 | ||
diff --git a/arch/arm/mach-s3c64xx/include/mach/crag6410.h b/arch/arm/mach-s3c64xx/include/mach/crag6410.h new file mode 100644 index 000000000000..be9074e17dfd --- /dev/null +++ b/arch/arm/mach-s3c64xx/include/mach/crag6410.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /* Cragganmore 6410 shared definitions | ||
2 | * | ||
3 | * Copyright 2011 Wolfson Microelectronics plc | ||
4 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #ifndef MACH_CRAG6410_H | ||
12 | #define MACH_CRAG6410_H | ||
13 | |||
14 | #include <linux/gpio.h> | ||
15 | |||
16 | #define BANFF_PMIC_IRQ_BASE IRQ_BOARD_START | ||
17 | #define GLENFARCLAS_PMIC_IRQ_BASE (IRQ_BOARD_START + 64) | ||
18 | |||
19 | #define PCA935X_GPIO_BASE GPIO_BOARD_START | ||
20 | #define CODEC_GPIO_BASE (GPIO_BOARD_START + 8) | ||
21 | #define GLENFARCLAS_PMIC_GPIO_BASE (GPIO_BOARD_START + 16) | ||
22 | |||
23 | #endif | ||
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c new file mode 100644 index 000000000000..0708fa01db9c --- /dev/null +++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c | |||
@@ -0,0 +1,173 @@ | |||
1 | /* Speyside modules for Cragganmore - board data probing | ||
2 | * | ||
3 | * Copyright 2011 Wolfson Microelectronics plc | ||
4 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/i2c.h> | ||
14 | |||
15 | #include <linux/mfd/wm831x/irq.h> | ||
16 | #include <linux/mfd/wm831x/gpio.h> | ||
17 | |||
18 | #include <sound/wm8996.h> | ||
19 | #include <sound/wm8962.h> | ||
20 | #include <sound/wm9081.h> | ||
21 | |||
22 | #include <mach/crag6410.h> | ||
23 | |||
24 | static struct wm8996_retune_mobile_config wm8996_retune[] = { | ||
25 | { | ||
26 | .name = "Sub LPF", | ||
27 | .rate = 48000, | ||
28 | .regs = { | ||
29 | 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
30 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
31 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
32 | }, | ||
33 | }, | ||
34 | { | ||
35 | .name = "Sub HPF", | ||
36 | .rate = 48000, | ||
37 | .regs = { | ||
38 | 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
39 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
40 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
41 | }, | ||
42 | }, | ||
43 | }; | ||
44 | |||
45 | static struct wm8996_pdata wm8996_pdata __initdata = { | ||
46 | .ldo_ena = S3C64XX_GPN(7), | ||
47 | .gpio_base = CODEC_GPIO_BASE, | ||
48 | .micdet_def = 1, | ||
49 | .inl_mode = WM8996_DIFFERRENTIAL_1, | ||
50 | .inr_mode = WM8996_DIFFERRENTIAL_1, | ||
51 | |||
52 | .irq_flags = IRQF_TRIGGER_RISING, | ||
53 | |||
54 | .gpio_default = { | ||
55 | 0x8001, /* GPIO1 == ADCLRCLK1 */ | ||
56 | 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */ | ||
57 | 0x0141, /* GPIO3 == HP_SEL */ | ||
58 | 0x0002, /* GPIO4 == IRQ */ | ||
59 | 0x020e, /* GPIO5 == CLKOUT */ | ||
60 | }, | ||
61 | |||
62 | .retune_mobile_cfgs = wm8996_retune, | ||
63 | .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune), | ||
64 | }; | ||
65 | |||
66 | static struct wm8962_pdata wm8962_pdata __initdata = { | ||
67 | .gpio_init = { | ||
68 | 0, | ||
69 | WM8962_GPIO_FN_OPCLK, | ||
70 | WM8962_GPIO_FN_DMICCLK, | ||
71 | 0, | ||
72 | 0x8000 | WM8962_GPIO_FN_DMICDAT, | ||
73 | WM8962_GPIO_FN_IRQ, /* Open drain mode */ | ||
74 | }, | ||
75 | .irq_active_low = true, | ||
76 | }; | ||
77 | |||
78 | static struct wm9081_pdata wm9081_pdata __initdata = { | ||
79 | .irq_high = false, | ||
80 | .irq_cmos = false, | ||
81 | }; | ||
82 | |||
83 | static const struct i2c_board_info wm1254_devs[] = { | ||
84 | { I2C_BOARD_INFO("wm8996", 0x1a), | ||
85 | .platform_data = &wm8996_pdata, | ||
86 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
87 | }, | ||
88 | { I2C_BOARD_INFO("wm9081", 0x6c), | ||
89 | .platform_data = &wm9081_pdata, }, | ||
90 | }; | ||
91 | |||
92 | static const struct i2c_board_info wm1259_devs[] = { | ||
93 | { I2C_BOARD_INFO("wm8962", 0x1a), | ||
94 | .platform_data = &wm8962_pdata, | ||
95 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
96 | }, | ||
97 | }; | ||
98 | |||
99 | |||
100 | static __devinitdata const struct { | ||
101 | u8 id; | ||
102 | const char *name; | ||
103 | const struct i2c_board_info *i2c_devs; | ||
104 | int num_i2c_devs; | ||
105 | } gf_mods[] = { | ||
106 | { .id = 0x01, .name = "1250-EV1 Springbank" }, | ||
107 | { .id = 0x02, .name = "1251-EV1 Jura" }, | ||
108 | { .id = 0x03, .name = "1252-EV1 Glenlivet" }, | ||
109 | { .id = 0x11, .name = "6249-EV2 Glenfarclas", }, | ||
110 | { .id = 0x21, .name = "1275-EV1 Mortlach" }, | ||
111 | { .id = 0x25, .name = "1274-EV1 Glencadam" }, | ||
112 | { .id = 0x31, .name = "1253-EV1 Tomatin", }, | ||
113 | { .id = 0x39, .name = "1254-EV1 Dallas Dhu", | ||
114 | .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, | ||
115 | { .id = 0x3a, .name = "1259-EV1 Tobermory", | ||
116 | .i2c_devs = wm1259_devs, .num_i2c_devs = ARRAY_SIZE(wm1259_devs) }, | ||
117 | { .id = 0x3b, .name = "1255-EV1 Kilchoman" }, | ||
118 | { .id = 0x3c, .name = "1273-EV1 Longmorn" }, | ||
119 | }; | ||
120 | |||
121 | static __devinit int wlf_gf_module_probe(struct i2c_client *i2c, | ||
122 | const struct i2c_device_id *i2c_id) | ||
123 | { | ||
124 | int ret, i, j, id, rev; | ||
125 | |||
126 | ret = i2c_smbus_read_byte_data(i2c, 0); | ||
127 | if (ret < 0) { | ||
128 | dev_err(&i2c->dev, "Failed to read ID: %d\n", ret); | ||
129 | return ret; | ||
130 | } | ||
131 | |||
132 | id = (ret & 0xfe) >> 2; | ||
133 | rev = ret & 0x3; | ||
134 | for (i = 0; i < ARRAY_SIZE(gf_mods); i++) | ||
135 | if (id == gf_mods[i].id) | ||
136 | break; | ||
137 | |||
138 | if (i < ARRAY_SIZE(gf_mods)) { | ||
139 | dev_info(&i2c->dev, "%s revision %d\n", | ||
140 | gf_mods[i].name, rev + 1); | ||
141 | for (j = 0; j < gf_mods[i].num_i2c_devs; j++) { | ||
142 | if (!i2c_new_device(i2c->adapter, | ||
143 | &(gf_mods[i].i2c_devs[j]))) | ||
144 | dev_err(&i2c->dev, | ||
145 | "Failed to register dev: %d\n", ret); | ||
146 | } | ||
147 | } else { | ||
148 | dev_warn(&i2c->dev, "Unknown module ID %d revision %d\n", | ||
149 | id, rev); | ||
150 | } | ||
151 | |||
152 | return 0; | ||
153 | } | ||
154 | |||
155 | static const struct i2c_device_id wlf_gf_module_id[] = { | ||
156 | { "wlf-gf-module", 0 }, | ||
157 | { } | ||
158 | }; | ||
159 | |||
160 | static struct i2c_driver wlf_gf_module_driver = { | ||
161 | .driver = { | ||
162 | .name = "wlf-gf-module", | ||
163 | .owner = THIS_MODULE, | ||
164 | }, | ||
165 | .probe = wlf_gf_module_probe, | ||
166 | .id_table = wlf_gf_module_id, | ||
167 | }; | ||
168 | |||
169 | static int __init wlf_gf_module_register(void) | ||
170 | { | ||
171 | return i2c_add_driver(&wlf_gf_module_driver); | ||
172 | } | ||
173 | module_init(wlf_gf_module_register); | ||
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c index 5affb26a1985..1ef53b28f683 100644 --- a/arch/arm/mach-s3c64xx/mach-crag6410.c +++ b/arch/arm/mach-s3c64xx/mach-crag6410.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <mach/regs-sys.h> | 47 | #include <mach/regs-sys.h> |
48 | #include <mach/regs-gpio.h> | 48 | #include <mach/regs-gpio.h> |
49 | #include <mach/regs-modem.h> | 49 | #include <mach/regs-modem.h> |
50 | #include <mach/crag6410.h> | ||
50 | 51 | ||
51 | #include <mach/regs-gpio-memport.h> | 52 | #include <mach/regs-gpio-memport.h> |
52 | 53 | ||
@@ -65,17 +66,6 @@ | |||
65 | #include <plat/iic.h> | 66 | #include <plat/iic.h> |
66 | #include <plat/pm.h> | 67 | #include <plat/pm.h> |
67 | 68 | ||
68 | #include <sound/wm8996.h> | ||
69 | #include <sound/wm8962.h> | ||
70 | #include <sound/wm9081.h> | ||
71 | |||
72 | #define BANFF_PMIC_IRQ_BASE IRQ_BOARD_START | ||
73 | #define GLENFARCLAS_PMIC_IRQ_BASE (IRQ_BOARD_START + 64) | ||
74 | |||
75 | #define PCA935X_GPIO_BASE GPIO_BOARD_START | ||
76 | #define CODEC_GPIO_BASE (GPIO_BOARD_START + 8) | ||
77 | #define GLENFARCLAS_PMIC_GPIO_BASE (GPIO_BOARD_START + 16) | ||
78 | |||
79 | /* serial port setup */ | 69 | /* serial port setup */ |
80 | 70 | ||
81 | #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK) | 71 | #define UCON (S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK) |
@@ -623,81 +613,16 @@ static struct wm831x_pdata glenfarclas_pmic_pdata __initdata = { | |||
623 | .disable_touch = true, | 613 | .disable_touch = true, |
624 | }; | 614 | }; |
625 | 615 | ||
626 | static struct wm8996_retune_mobile_config wm8996_retune[] = { | ||
627 | { | ||
628 | .name = "Sub LPF", | ||
629 | .rate = 48000, | ||
630 | .regs = { | ||
631 | 0x6318, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
632 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
633 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
634 | }, | ||
635 | }, | ||
636 | { | ||
637 | .name = "Sub HPF", | ||
638 | .rate = 48000, | ||
639 | .regs = { | ||
640 | 0x000A, 0x6300, 0x1000, 0x0000, 0x0004, 0x2000, 0xF000, | ||
641 | 0x0000, 0x0004, 0x2000, 0xF000, 0x0000, 0x0004, 0x2000, | ||
642 | 0xF000, 0x0000, 0x0004, 0x1000, 0x0800, 0x4000 | ||
643 | }, | ||
644 | }, | ||
645 | }; | ||
646 | |||
647 | static struct wm8996_pdata wm8996_pdata __initdata = { | ||
648 | .ldo_ena = S3C64XX_GPN(7), | ||
649 | .gpio_base = CODEC_GPIO_BASE, | ||
650 | .micdet_def = 1, | ||
651 | .inl_mode = WM8996_DIFFERRENTIAL_1, | ||
652 | .inr_mode = WM8996_DIFFERRENTIAL_1, | ||
653 | |||
654 | .irq_flags = IRQF_TRIGGER_RISING, | ||
655 | |||
656 | .gpio_default = { | ||
657 | 0x8001, /* GPIO1 == ADCLRCLK1 */ | ||
658 | 0x8001, /* GPIO2 == ADCLRCLK2, input due to CPU */ | ||
659 | 0x0141, /* GPIO3 == HP_SEL */ | ||
660 | 0x0002, /* GPIO4 == IRQ */ | ||
661 | 0x020e, /* GPIO5 == CLKOUT */ | ||
662 | }, | ||
663 | |||
664 | .retune_mobile_cfgs = wm8996_retune, | ||
665 | .num_retune_mobile_cfgs = ARRAY_SIZE(wm8996_retune), | ||
666 | }; | ||
667 | |||
668 | static struct wm8962_pdata wm8962_pdata __initdata = { | ||
669 | .gpio_init = { | ||
670 | 0, | ||
671 | WM8962_GPIO_FN_OPCLK, | ||
672 | WM8962_GPIO_FN_DMICCLK, | ||
673 | 0, | ||
674 | 0x8000 | WM8962_GPIO_FN_DMICDAT, | ||
675 | WM8962_GPIO_FN_IRQ, /* Open drain mode */ | ||
676 | }, | ||
677 | .irq_active_low = true, | ||
678 | }; | ||
679 | |||
680 | static struct wm9081_pdata wm9081_pdata __initdata = { | ||
681 | .irq_high = false, | ||
682 | .irq_cmos = false, | ||
683 | }; | ||
684 | |||
685 | static struct i2c_board_info i2c_devs1[] __initdata = { | 616 | static struct i2c_board_info i2c_devs1[] __initdata = { |
686 | { I2C_BOARD_INFO("wm8311", 0x34), | 617 | { I2C_BOARD_INFO("wm8311", 0x34), |
687 | .irq = S3C_EINT(0), | 618 | .irq = S3C_EINT(0), |
688 | .platform_data = &glenfarclas_pmic_pdata }, | 619 | .platform_data = &glenfarclas_pmic_pdata }, |
689 | 620 | ||
621 | { I2C_BOARD_INFO("wlf-gf-module", 0x24) }, | ||
622 | { I2C_BOARD_INFO("wlf-gf-module", 0x25) }, | ||
623 | { I2C_BOARD_INFO("wlf-gf-module", 0x26) }, | ||
624 | |||
690 | { I2C_BOARD_INFO("wm1250-ev1", 0x27) }, | 625 | { I2C_BOARD_INFO("wm1250-ev1", 0x27) }, |
691 | { I2C_BOARD_INFO("wm8996", 0x1a), | ||
692 | .platform_data = &wm8996_pdata, | ||
693 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
694 | }, | ||
695 | { I2C_BOARD_INFO("wm9081", 0x6c), | ||
696 | .platform_data = &wm9081_pdata, }, | ||
697 | { I2C_BOARD_INFO("wm8962", 0x1a), | ||
698 | .platform_data = &wm8962_pdata, | ||
699 | .irq = GLENFARCLAS_PMIC_IRQ_BASE + WM831X_IRQ_GPIO_2, | ||
700 | }, | ||
701 | }; | 626 | }; |
702 | 627 | ||
703 | static void __init crag6410_map_io(void) | 628 | static void __init crag6410_map_io(void) |