.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Versatile board support using the device tree |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Copyright (C) 2009 Jeremy Kerr <jeremy.kerr@canonical.com> |
---|
6 | 7 | * Copyright (C) 2004 ARM Limited |
---|
7 | 8 | * Copyright (C) 2000 Deep Blue Solutions Ltd |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License as published by |
---|
11 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
12 | | - * (at your option) any later version. |
---|
13 | | - * |
---|
14 | | - * This program is distributed in the hope that it will be useful, |
---|
15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | | - * GNU General Public License for more details. |
---|
18 | | - * |
---|
19 | | - * You should have received a copy of the GNU General Public License |
---|
20 | | - * along with this program; if not, write to the Free Software |
---|
21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
22 | 9 | */ |
---|
23 | 10 | |
---|
24 | 11 | #include <linux/init.h> |
---|
.. | .. |
---|
29 | 16 | #include <linux/of_platform.h> |
---|
30 | 17 | #include <linux/slab.h> |
---|
31 | 18 | #include <linux/amba/bus.h> |
---|
32 | | -#include <linux/amba/clcd.h> |
---|
33 | | -#include <linux/platform_data/video-clcd-versatile.h> |
---|
34 | 19 | #include <linux/amba/mmci.h> |
---|
35 | 20 | #include <asm/mach-types.h> |
---|
36 | 21 | #include <asm/mach/arch.h> |
---|
.. | .. |
---|
47 | 32 | */ |
---|
48 | 33 | #define VERSATILE_SYS_PCICTL_OFFSET 0x44 |
---|
49 | 34 | #define VERSATILE_SYS_MCI_OFFSET 0x48 |
---|
50 | | -#define VERSATILE_SYS_CLCD_OFFSET 0x50 |
---|
51 | 35 | |
---|
52 | 36 | /* |
---|
53 | 37 | * VERSATILE peripheral addresses |
---|
54 | 38 | */ |
---|
55 | 39 | #define VERSATILE_MMCI0_BASE 0x10005000 /* MMC interface */ |
---|
56 | 40 | #define VERSATILE_MMCI1_BASE 0x1000B000 /* MMC Interface */ |
---|
57 | | -#define VERSATILE_CLCD_BASE 0x10120000 /* CLCD */ |
---|
58 | 41 | #define VERSATILE_SCTL_BASE 0x101E0000 /* System controller */ |
---|
59 | | -#define VERSATILE_IB2_BASE 0x24000000 /* IB2 module */ |
---|
60 | | -#define VERSATILE_IB2_CTL_BASE (VERSATILE_IB2_BASE + 0x03000000) |
---|
61 | 42 | |
---|
62 | 43 | /* |
---|
63 | 44 | * System controller bit assignment |
---|
.. | .. |
---|
71 | 52 | #define VERSATILE_TIMER4_EnSel 21 |
---|
72 | 53 | |
---|
73 | 54 | static void __iomem *versatile_sys_base; |
---|
74 | | -static void __iomem *versatile_ib2_ctrl; |
---|
75 | 55 | |
---|
76 | 56 | unsigned int mmc_status(struct device *dev) |
---|
77 | 57 | { |
---|
.. | .. |
---|
89 | 69 | static struct mmci_platform_data mmc0_plat_data = { |
---|
90 | 70 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
---|
91 | 71 | .status = mmc_status, |
---|
92 | | - .gpio_wp = -1, |
---|
93 | | - .gpio_cd = -1, |
---|
94 | 72 | }; |
---|
95 | 73 | |
---|
96 | 74 | static struct mmci_platform_data mmc1_plat_data = { |
---|
97 | 75 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
---|
98 | 76 | .status = mmc_status, |
---|
99 | | - .gpio_wp = -1, |
---|
100 | | - .gpio_cd = -1, |
---|
101 | | -}; |
---|
102 | | - |
---|
103 | | -/* |
---|
104 | | - * CLCD support. |
---|
105 | | - */ |
---|
106 | | -#define SYS_CLCD_MODE_MASK (3 << 0) |
---|
107 | | -#define SYS_CLCD_MODE_888 (0 << 0) |
---|
108 | | -#define SYS_CLCD_MODE_5551 (1 << 0) |
---|
109 | | -#define SYS_CLCD_MODE_565_RLSB (2 << 0) |
---|
110 | | -#define SYS_CLCD_MODE_565_BLSB (3 << 0) |
---|
111 | | -#define SYS_CLCD_NLCDIOON (1 << 2) |
---|
112 | | -#define SYS_CLCD_VDDPOSSWITCH (1 << 3) |
---|
113 | | -#define SYS_CLCD_PWR3V5SWITCH (1 << 4) |
---|
114 | | -#define SYS_CLCD_ID_MASK (0x1f << 8) |
---|
115 | | -#define SYS_CLCD_ID_SANYO_3_8 (0x00 << 8) |
---|
116 | | -#define SYS_CLCD_ID_UNKNOWN_8_4 (0x01 << 8) |
---|
117 | | -#define SYS_CLCD_ID_EPSON_2_2 (0x02 << 8) |
---|
118 | | -#define SYS_CLCD_ID_SANYO_2_5 (0x07 << 8) |
---|
119 | | -#define SYS_CLCD_ID_VGA (0x1f << 8) |
---|
120 | | - |
---|
121 | | -static bool is_sanyo_2_5_lcd; |
---|
122 | | - |
---|
123 | | -/* |
---|
124 | | - * Disable all display connectors on the interface module. |
---|
125 | | - */ |
---|
126 | | -static void versatile_clcd_disable(struct clcd_fb *fb) |
---|
127 | | -{ |
---|
128 | | - void __iomem *sys_clcd = versatile_sys_base + VERSATILE_SYS_CLCD_OFFSET; |
---|
129 | | - u32 val; |
---|
130 | | - |
---|
131 | | - val = readl(sys_clcd); |
---|
132 | | - val &= ~SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH; |
---|
133 | | - writel(val, sys_clcd); |
---|
134 | | - |
---|
135 | | - /* |
---|
136 | | - * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off |
---|
137 | | - */ |
---|
138 | | - if (of_machine_is_compatible("arm,versatile-ab") && is_sanyo_2_5_lcd) { |
---|
139 | | - unsigned long ctrl; |
---|
140 | | - |
---|
141 | | - ctrl = readl(versatile_ib2_ctrl); |
---|
142 | | - ctrl &= ~0x01; |
---|
143 | | - writel(ctrl, versatile_ib2_ctrl); |
---|
144 | | - } |
---|
145 | | -} |
---|
146 | | - |
---|
147 | | -/* |
---|
148 | | - * Enable the relevant connector on the interface module. |
---|
149 | | - */ |
---|
150 | | -static void versatile_clcd_enable(struct clcd_fb *fb) |
---|
151 | | -{ |
---|
152 | | - struct fb_var_screeninfo *var = &fb->fb.var; |
---|
153 | | - void __iomem *sys_clcd = versatile_sys_base + VERSATILE_SYS_CLCD_OFFSET; |
---|
154 | | - u32 val; |
---|
155 | | - |
---|
156 | | - val = readl(sys_clcd); |
---|
157 | | - val &= ~SYS_CLCD_MODE_MASK; |
---|
158 | | - |
---|
159 | | - switch (var->green.length) { |
---|
160 | | - case 5: |
---|
161 | | - val |= SYS_CLCD_MODE_5551; |
---|
162 | | - break; |
---|
163 | | - case 6: |
---|
164 | | - if (var->red.offset == 0) |
---|
165 | | - val |= SYS_CLCD_MODE_565_RLSB; |
---|
166 | | - else |
---|
167 | | - val |= SYS_CLCD_MODE_565_BLSB; |
---|
168 | | - break; |
---|
169 | | - case 8: |
---|
170 | | - val |= SYS_CLCD_MODE_888; |
---|
171 | | - break; |
---|
172 | | - } |
---|
173 | | - |
---|
174 | | - /* |
---|
175 | | - * Set the MUX |
---|
176 | | - */ |
---|
177 | | - writel(val, sys_clcd); |
---|
178 | | - |
---|
179 | | - /* |
---|
180 | | - * And now enable the PSUs |
---|
181 | | - */ |
---|
182 | | - val |= SYS_CLCD_NLCDIOON | SYS_CLCD_PWR3V5SWITCH; |
---|
183 | | - writel(val, sys_clcd); |
---|
184 | | - |
---|
185 | | - /* |
---|
186 | | - * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on |
---|
187 | | - */ |
---|
188 | | - if (of_machine_is_compatible("arm,versatile-ab") && is_sanyo_2_5_lcd) { |
---|
189 | | - unsigned long ctrl; |
---|
190 | | - |
---|
191 | | - ctrl = readl(versatile_ib2_ctrl); |
---|
192 | | - ctrl |= 0x01; |
---|
193 | | - writel(ctrl, versatile_ib2_ctrl); |
---|
194 | | - } |
---|
195 | | -} |
---|
196 | | - |
---|
197 | | -/* |
---|
198 | | - * Detect which LCD panel is connected, and return the appropriate |
---|
199 | | - * clcd_panel structure. Note: we do not have any information on |
---|
200 | | - * the required timings for the 8.4in panel, so we presently assume |
---|
201 | | - * VGA timings. |
---|
202 | | - */ |
---|
203 | | -static int versatile_clcd_setup(struct clcd_fb *fb) |
---|
204 | | -{ |
---|
205 | | - void __iomem *sys_clcd = versatile_sys_base + VERSATILE_SYS_CLCD_OFFSET; |
---|
206 | | - const char *panel_name; |
---|
207 | | - u32 val; |
---|
208 | | - |
---|
209 | | - is_sanyo_2_5_lcd = false; |
---|
210 | | - |
---|
211 | | - val = readl(sys_clcd) & SYS_CLCD_ID_MASK; |
---|
212 | | - if (val == SYS_CLCD_ID_SANYO_3_8) |
---|
213 | | - panel_name = "Sanyo TM38QV67A02A"; |
---|
214 | | - else if (val == SYS_CLCD_ID_SANYO_2_5) { |
---|
215 | | - panel_name = "Sanyo QVGA Portrait"; |
---|
216 | | - is_sanyo_2_5_lcd = true; |
---|
217 | | - } else if (val == SYS_CLCD_ID_EPSON_2_2) |
---|
218 | | - panel_name = "Epson L2F50113T00"; |
---|
219 | | - else if (val == SYS_CLCD_ID_VGA) |
---|
220 | | - panel_name = "VGA"; |
---|
221 | | - else { |
---|
222 | | - printk(KERN_ERR "CLCD: unknown LCD panel ID 0x%08x, using VGA\n", |
---|
223 | | - val); |
---|
224 | | - panel_name = "VGA"; |
---|
225 | | - } |
---|
226 | | - |
---|
227 | | - fb->panel = versatile_clcd_get_panel(panel_name); |
---|
228 | | - if (!fb->panel) |
---|
229 | | - return -EINVAL; |
---|
230 | | - |
---|
231 | | - return versatile_clcd_setup_dma(fb, SZ_1M); |
---|
232 | | -} |
---|
233 | | - |
---|
234 | | -static void versatile_clcd_decode(struct clcd_fb *fb, struct clcd_regs *regs) |
---|
235 | | -{ |
---|
236 | | - clcdfb_decode(fb, regs); |
---|
237 | | - |
---|
238 | | - /* Always clear BGR for RGB565: we do the routing externally */ |
---|
239 | | - if (fb->fb.var.green.length == 6) |
---|
240 | | - regs->cntl &= ~CNTL_BGR; |
---|
241 | | -} |
---|
242 | | - |
---|
243 | | -static struct clcd_board clcd_plat_data = { |
---|
244 | | - .name = "Versatile", |
---|
245 | | - .caps = CLCD_CAP_5551 | CLCD_CAP_565 | CLCD_CAP_888, |
---|
246 | | - .check = clcdfb_check, |
---|
247 | | - .decode = versatile_clcd_decode, |
---|
248 | | - .disable = versatile_clcd_disable, |
---|
249 | | - .enable = versatile_clcd_enable, |
---|
250 | | - .setup = versatile_clcd_setup, |
---|
251 | | - .mmap = versatile_clcd_mmap_dma, |
---|
252 | | - .remove = versatile_clcd_remove_dma, |
---|
253 | 77 | }; |
---|
254 | 78 | |
---|
255 | 79 | /* |
---|
.. | .. |
---|
261 | 85 | struct of_dev_auxdata versatile_auxdata_lookup[] __initdata = { |
---|
262 | 86 | OF_DEV_AUXDATA("arm,primecell", VERSATILE_MMCI0_BASE, "fpga:05", &mmc0_plat_data), |
---|
263 | 87 | OF_DEV_AUXDATA("arm,primecell", VERSATILE_MMCI1_BASE, "fpga:0b", &mmc1_plat_data), |
---|
264 | | - OF_DEV_AUXDATA("arm,primecell", VERSATILE_CLCD_BASE, "dev:20", &clcd_plat_data), |
---|
265 | 88 | {} |
---|
266 | 89 | }; |
---|
267 | 90 | |
---|
.. | .. |
---|
316 | 139 | * driver had it so we will keep it. |
---|
317 | 140 | */ |
---|
318 | 141 | writel(1, versatile_sys_base + VERSATILE_SYS_PCICTL_OFFSET); |
---|
319 | | - return; |
---|
| 142 | + goto out_put_node; |
---|
320 | 143 | } |
---|
321 | 144 | |
---|
322 | 145 | newprop = kzalloc(sizeof(*newprop), GFP_KERNEL); |
---|
323 | 146 | if (!newprop) |
---|
324 | | - return; |
---|
| 147 | + goto out_put_node; |
---|
325 | 148 | |
---|
326 | 149 | newprop->name = kstrdup("status", GFP_KERNEL); |
---|
327 | 150 | newprop->value = kstrdup("disabled", GFP_KERNEL); |
---|
.. | .. |
---|
329 | 152 | of_update_property(np, newprop); |
---|
330 | 153 | |
---|
331 | 154 | pr_info("Not plugged into PCI backplane!\n"); |
---|
| 155 | + |
---|
| 156 | +out_put_node: |
---|
| 157 | + of_node_put(np); |
---|
332 | 158 | } |
---|
333 | 159 | |
---|
334 | 160 | static void __init versatile_dt_init(void) |
---|
.. | .. |
---|
339 | 165 | if (np) |
---|
340 | 166 | versatile_sys_base = of_iomap(np, 0); |
---|
341 | 167 | WARN_ON(!versatile_sys_base); |
---|
342 | | - |
---|
343 | | - versatile_ib2_ctrl = ioremap(VERSATILE_IB2_CTL_BASE, SZ_4K); |
---|
344 | 168 | |
---|
345 | 169 | versatile_dt_pci_init(); |
---|
346 | 170 | |
---|