blob: edb9e59248ecea7860dde0f16c5623a54d00e16b [file] [log] [blame]
Ralf Baechle832348f2007-10-18 01:10:12 +01001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 *
7 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
8 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
10 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
11 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
12 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
13 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
14 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
16 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
Ralf Baechle832348f2007-10-18 01:10:12 +010022 * Copyright 2001 MontaVista Software Inc.
23 * Author: MontaVista Software, Inc.
24 * ahennessy@mvista.com
25 *
26 * Copyright (C) 2000-2001 Toshiba Corporation
27 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 */
29
Ralf Baechle832348f2007-10-18 01:10:12 +010030#include <linux/clockchips.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/init.h>
32#include <linux/kernel.h>
33#include <linux/kdev_t.h>
34#include <linux/types.h>
35#include <linux/sched.h>
36#include <linux/pci.h>
37#include <linux/ide.h>
Ralf Baechle046f8f72006-07-09 20:49:41 +010038#include <linux/irq.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/ioport.h>
40#include <linux/param.h> /* for HZ */
41#include <linux/delay.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000042#include <linux/pm.h>
Atsushi Nemotoa0574e02007-03-01 00:40:21 +090043#include <linux/platform_device.h>
Ralf Baechle5eaf7a22005-03-04 17:24:32 +000044#ifdef CONFIG_SERIAL_TXX9
45#include <linux/tty.h>
46#include <linux/serial.h>
47#include <linux/serial_core.h>
48#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#include <asm/addrspace.h>
51#include <asm/time.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <asm/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070053#include <asm/jmr3927/jmr3927.h>
54#include <asm/mipsregs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Atsushi Nemoto21274352007-03-15 00:58:28 +090056extern void puts(const char *cp);
Ralf Baechle380b9252005-11-19 21:51:56 +000057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/* Tick Timer divider */
59#define JMR3927_TIMER_CCD 0 /* 1/2 */
60#define JMR3927_TIMER_CLK (JMR3927_IMCLK / (2 << JMR3927_TIMER_CCD))
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062/* don't enable - see errata */
Atsushi Nemoto21274352007-03-15 00:58:28 +090063static int jmr3927_ccfg_toeon;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65static inline void do_reset(void)
66{
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#if 1 /* Resetting PCI bus */
68 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
69 jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI, JMR3927_IOC_RESET_ADDR);
70 (void)jmr3927_ioc_reg_in(JMR3927_IOC_RESET_ADDR); /* flush WB */
71 mdelay(1);
72 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
73#endif
74 jmr3927_ioc_reg_out(JMR3927_IOC_RESET_CPU, JMR3927_IOC_RESET_ADDR);
75}
76
77static void jmr3927_machine_restart(char *command)
78{
79 local_irq_disable();
80 puts("Rebooting...");
81 do_reset();
82}
83
84static void jmr3927_machine_halt(void)
85{
86 puts("JMR-TX3927 halted.\n");
87 while (1);
88}
89
90static void jmr3927_machine_power_off(void)
91{
92 puts("JMR-TX3927 halted. Please turn off the power.\n");
93 while (1);
94}
95
Atsushi Nemoto00598562006-11-12 00:10:28 +090096static cycle_t jmr3927_hpt_read(void)
Atsushi Nemoto16b7b2a2006-10-24 00:21:27 +090097{
98 /* We assume this function is called xtime_lock held. */
99 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
100}
101
Ralf Baechle832348f2007-10-18 01:10:12 +0100102static void jmr3927_set_mode(enum clock_event_mode mode,
103 struct clock_event_device *evt)
Atsushi Nemoto21274352007-03-15 00:58:28 +0900104{
Ralf Baechle832348f2007-10-18 01:10:12 +0100105 /* Nothing to do here */
Atsushi Nemoto21274352007-03-15 00:58:28 +0900106}
107
Ralf Baechle832348f2007-10-18 01:10:12 +0100108struct clock_event_device jmr3927_clock_event_device = {
109 .name = "MIPS",
110 .features = CLOCK_EVT_FEAT_PERIODIC,
111 .shift = 32,
112 .rating = 300,
113 .cpumask = CPU_MASK_CPU0,
114 .irq = JMR3927_IRQ_TICK,
115 .set_mode = jmr3927_set_mode,
116};
117
118static irqreturn_t jmr3927_timer_interrupt(int irq, void *dev_id)
119{
120 struct clock_event_device *cd = &jmr3927_clock_event_device;
121
122 jmr3927_tmrptr->tisr = 0; /* ack interrupt */
123
124 cd->event_handler(cd);
125
126 return IRQ_HANDLED;
127}
128
129static struct irqaction jmr3927_timer_irqaction = {
130 .handler = jmr3927_timer_interrupt,
131 .flags = IRQF_DISABLED | IRQF_PERCPU,
132 .name = "jmr3927-timer",
133};
134
Ralf Baechle4b550482007-10-11 23:46:08 +0100135void __init plat_time_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136{
Ralf Baechle832348f2007-10-18 01:10:12 +0100137 struct clock_event_device *cd;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138
Ralf Baechle832348f2007-10-18 01:10:12 +0100139 clocksource_mips.read = jmr3927_hpt_read;
140 mips_hpt_frequency = JMR3927_TIMER_CLK;
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ;
143 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE;
144 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD;
145 jmr3927_tmrptr->tcr =
146 TXx927_TMTCR_TCE | TXx927_TMTCR_CCDE | TXx927_TMTCR_TMODE_ITVL;
147
Ralf Baechle832348f2007-10-18 01:10:12 +0100148 cd = &jmr3927_clock_event_device;
149 /* Calculate the min / max delta */
150 cd->mult = div_sc((unsigned long) JMR3927_IMCLK, NSEC_PER_SEC, 32);
151 cd->max_delta_ns = clockevent_delta2ns(0x7fffffff, cd);
152 cd->min_delta_ns = clockevent_delta2ns(0x300, cd);
153 clockevents_register_device(cd);
154
155 setup_irq(JMR3927_IRQ_TICK, &jmr3927_timer_irqaction);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156}
157
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158#define DO_WRITE_THROUGH
159#define DO_ENABLE_CACHE
160
161extern char * __init prom_getcmdline(void);
162static void jmr3927_board_init(void);
163extern struct resource pci_io_resource;
164extern struct resource pci_mem_resource;
165
Ralf Baechle2925aba2006-06-18 01:32:22 +0100166void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 char *argptr;
169
170 set_io_port_base(JMR3927_PORT_BASE + JMR3927_PCIIO);
171
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 _machine_restart = jmr3927_machine_restart;
173 _machine_halt = jmr3927_machine_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000174 pm_power_off = jmr3927_machine_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176 /*
177 * IO/MEM resources.
178 */
179 ioport_resource.start = pci_io_resource.start;
180 ioport_resource.end = pci_io_resource.end;
Ralf Baechle5eaf7a22005-03-04 17:24:32 +0000181 iomem_resource.start = 0;
182 iomem_resource.end = 0xffffffff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184 /* Reboot on panic */
185 panic_timeout = 180;
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 /* cache setup */
188 {
189 unsigned int conf;
190#ifdef DO_ENABLE_CACHE
191 int mips_ic_disable = 0, mips_dc_disable = 0;
192#else
193 int mips_ic_disable = 1, mips_dc_disable = 1;
194#endif
195#ifdef DO_WRITE_THROUGH
196 int mips_config_cwfon = 0;
197 int mips_config_wbon = 0;
198#else
199 int mips_config_cwfon = 1;
200 int mips_config_wbon = 1;
201#endif
202
203 conf = read_c0_conf();
204 conf &= ~(TX39_CONF_ICE | TX39_CONF_DCE | TX39_CONF_WBON | TX39_CONF_CWFON);
205 conf |= mips_ic_disable ? 0 : TX39_CONF_ICE;
206 conf |= mips_dc_disable ? 0 : TX39_CONF_DCE;
207 conf |= mips_config_wbon ? TX39_CONF_WBON : 0;
208 conf |= mips_config_cwfon ? TX39_CONF_CWFON : 0;
209
210 write_c0_conf(conf);
211 write_c0_cache(0);
212 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214 /* initialize board */
215 jmr3927_board_init();
216
217 argptr = prom_getcmdline();
218
Atsushi Nemoto21274352007-03-15 00:58:28 +0900219 if ((argptr = strstr(argptr, "toeon")) != NULL)
220 jmr3927_ccfg_toeon = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 argptr = prom_getcmdline();
222 if ((argptr = strstr(argptr, "ip=")) == NULL) {
223 argptr = prom_getcmdline();
224 strcat(argptr, " ip=bootp");
225 }
226
Ralf Baechle5eaf7a22005-03-04 17:24:32 +0000227#ifdef CONFIG_SERIAL_TXX9
228 {
229 extern int early_serial_txx9_setup(struct uart_port *port);
230 int i;
231 struct uart_port req;
232 for(i = 0; i < 2; i++) {
233 memset(&req, 0, sizeof(req));
234 req.line = i;
235 req.iotype = UPIO_MEM;
Atsushi Nemoto21274352007-03-15 00:58:28 +0900236 req.membase = (unsigned char __iomem *)TX3927_SIO_REG(i);
Ralf Baechle5eaf7a22005-03-04 17:24:32 +0000237 req.mapbase = TX3927_SIO_REG(i);
238 req.irq = i == 0 ?
239 JMR3927_IRQ_IRC_SIO0 : JMR3927_IRQ_IRC_SIO1;
240 if (i == 0)
241 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
242 req.uartclk = JMR3927_IMCLK;
243 early_serial_txx9_setup(&req);
244 }
245 }
246#ifdef CONFIG_SERIAL_TXX9_CONSOLE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 argptr = prom_getcmdline();
248 if ((argptr = strstr(argptr, "console=")) == NULL) {
249 argptr = prom_getcmdline();
250 strcat(argptr, " console=ttyS1,115200");
251 }
252#endif
Ralf Baechle5eaf7a22005-03-04 17:24:32 +0000253#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254}
255
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256static void tx3927_setup(void);
257
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258static void __init jmr3927_board_init(void)
259{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 tx3927_setup();
261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 /* SIO0 DTR on */
263 jmr3927_ioc_reg_out(0, JMR3927_IOC_DTR_ADDR);
264
265 jmr3927_led_set(0);
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 printk("JMR-TX3927 (Rev %d) --- IOC(Rev %d) DIPSW:%d,%d,%d,%d\n",
268 jmr3927_ioc_reg_in(JMR3927_IOC_BREV_ADDR) & JMR3927_REV_MASK,
269 jmr3927_ioc_reg_in(JMR3927_IOC_REV_ADDR) & JMR3927_REV_MASK,
270 jmr3927_dipsw1(), jmr3927_dipsw2(),
271 jmr3927_dipsw3(), jmr3927_dipsw4());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272}
273
Atsushi Nemoto21274352007-03-15 00:58:28 +0900274static void __init tx3927_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275{
276 int i;
Atsushi Nemoto21274352007-03-15 00:58:28 +0900277#ifdef CONFIG_PCI
278 unsigned long mips_pci_io_base = JMR3927_PCIIO;
279 unsigned long mips_pci_io_size = JMR3927_PCIIO_SIZE;
280 unsigned long mips_pci_mem_base = JMR3927_PCIMEM;
281 unsigned long mips_pci_mem_size = JMR3927_PCIMEM_SIZE;
282 /* for legacy I/O, PCI I/O PCI Bus address must be 0 */
283 unsigned long mips_pci_io_pciaddr = 0;
284#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 /* SDRAMC are configured by PROM */
287
288 /* ROMC */
289 tx3927_romcptr->cr[1] = JMR3927_ROMCE1 | 0x00030048;
290 tx3927_romcptr->cr[2] = JMR3927_ROMCE2 | 0x000064c8;
291 tx3927_romcptr->cr[3] = JMR3927_ROMCE3 | 0x0003f698;
292 tx3927_romcptr->cr[5] = JMR3927_ROMCE5 | 0x0000f218;
293
294 /* CCFG */
295 /* enable Timeout BusError */
296 if (jmr3927_ccfg_toeon)
297 tx3927_ccfgptr->ccfg |= TX3927_CCFG_TOE;
298
299 /* clear BusErrorOnWrite flag */
300 tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_BEOW;
301 /* Disable PCI snoop */
302 tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_PSNP;
303
304#ifdef DO_WRITE_THROUGH
305 /* Enable PCI SNOOP - with write through only */
306 tx3927_ccfgptr->ccfg |= TX3927_CCFG_PSNP;
307#endif
308
309 /* Pin selection */
310 tx3927_ccfgptr->pcfg &= ~TX3927_PCFG_SELALL;
311 tx3927_ccfgptr->pcfg |=
312 TX3927_PCFG_SELSIOC(0) | TX3927_PCFG_SELSIO_ALL |
313 (TX3927_PCFG_SELDMA_ALL & ~TX3927_PCFG_SELDMA(1));
314
315 printk("TX3927 -- CRIR:%08lx CCFG:%08lx PCFG:%08lx\n",
316 tx3927_ccfgptr->crir,
317 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg);
318
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 /* TMR */
320 /* disable all timers */
321 for (i = 0; i < TX3927_NR_TMR; i++) {
322 tx3927_tmrptr(i)->tcr = TXx927_TMTCR_CRE;
323 tx3927_tmrptr(i)->tisr = 0;
324 tx3927_tmrptr(i)->cpra = 0xffffffff;
325 tx3927_tmrptr(i)->itmr = 0;
326 tx3927_tmrptr(i)->ccdr = 0;
327 tx3927_tmrptr(i)->pgmr = 0;
328 }
329
330 /* DMA */
331 tx3927_dmaptr->mcr = 0;
Ahmed S. Darwish25b8ac32007-02-05 04:42:11 +0200332 for (i = 0; i < ARRAY_SIZE(tx3927_dmaptr->ch); i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 /* reset channel */
334 tx3927_dmaptr->ch[i].ccr = TX3927_DMA_CCR_CHRST;
335 tx3927_dmaptr->ch[i].ccr = 0;
336 }
337 /* enable DMA */
338#ifdef __BIG_ENDIAN
339 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN;
340#else
341 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE;
342#endif
343
344#ifdef CONFIG_PCI
345 /* PCIC */
346 printk("TX3927 PCIC -- DID:%04x VID:%04x RID:%02x Arbiter:",
347 tx3927_pcicptr->did, tx3927_pcicptr->vid,
348 tx3927_pcicptr->rid);
349 if (!(tx3927_ccfgptr->ccfg & TX3927_CCFG_PCIXARB)) {
350 printk("External\n");
351 /* XXX */
352 } else {
353 printk("Internal\n");
354
355 /* Reset PCI Bus */
356 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
357 udelay(100);
358 jmr3927_ioc_reg_out(JMR3927_IOC_RESET_PCI,
359 JMR3927_IOC_RESET_ADDR);
360 udelay(100);
361 jmr3927_ioc_reg_out(0, JMR3927_IOC_RESET_ADDR);
362
363
364 /* Disable External PCI Config. Access */
365 tx3927_pcicptr->lbc = TX3927_PCIC_LBC_EPCAD;
366#ifdef __BIG_ENDIAN
367 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_IBSE |
368 TX3927_PCIC_LBC_TIBSE |
369 TX3927_PCIC_LBC_TMFBSE | TX3927_PCIC_LBC_MSDSE;
370#endif
371 /* LB->PCI mappings */
372 tx3927_pcicptr->iomas = ~(mips_pci_io_size - 1);
373 tx3927_pcicptr->ilbioma = mips_pci_io_base;
374 tx3927_pcicptr->ipbioma = mips_pci_io_pciaddr;
375 tx3927_pcicptr->mmas = ~(mips_pci_mem_size - 1);
376 tx3927_pcicptr->ilbmma = mips_pci_mem_base;
377 tx3927_pcicptr->ipbmma = mips_pci_mem_base;
378 /* PCI->LB mappings */
379 tx3927_pcicptr->iobas = 0xffffffff;
380 tx3927_pcicptr->ioba = 0;
381 tx3927_pcicptr->tlbioma = 0;
382 tx3927_pcicptr->mbas = ~(mips_pci_mem_size - 1);
383 tx3927_pcicptr->mba = 0;
384 tx3927_pcicptr->tlbmma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 /* Enable Direct mapping Address Space Decoder */
386 tx3927_pcicptr->lbc |= TX3927_PCIC_LBC_ILMDE | TX3927_PCIC_LBC_ILIDE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387
388 /* Clear All Local Bus Status */
389 tx3927_pcicptr->lbstat = TX3927_PCIC_LBIM_ALL;
390 /* Enable All Local Bus Interrupts */
391 tx3927_pcicptr->lbim = TX3927_PCIC_LBIM_ALL;
392 /* Clear All PCI Status Error */
393 tx3927_pcicptr->pcistat = TX3927_PCIC_PCISTATIM_ALL;
394 /* Enable All PCI Status Error Interrupts */
395 tx3927_pcicptr->pcistatim = TX3927_PCIC_PCISTATIM_ALL;
396
397 /* PCIC Int => IRC IRQ10 */
398 tx3927_pcicptr->il = TX3927_IR_PCI;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 /* Target Control (per errata) */
400 tx3927_pcicptr->tc = TX3927_PCIC_TC_OF8E | TX3927_PCIC_TC_IF8E;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 /* Enable Bus Arbiter */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 tx3927_pcicptr->pbapmc = TX3927_PCIC_PBAPMC_PBAEN;
404
405 tx3927_pcicptr->pcicmd = PCI_COMMAND_MASTER |
406 PCI_COMMAND_MEMORY |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 PCI_COMMAND_IO |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 PCI_COMMAND_PARITY | PCI_COMMAND_SERR;
409 }
410#endif /* CONFIG_PCI */
411
412 /* PIO */
413 /* PIO[15:12] connected to LEDs */
414 tx3927_pioptr->dir = 0x0000f000;
415 tx3927_pioptr->maskcpu = 0;
416 tx3927_pioptr->maskext = 0;
417 {
418 unsigned int conf;
419
420 conf = read_c0_conf();
421 if (!(conf & TX39_CONF_ICE))
422 printk("TX3927 I-Cache disabled.\n");
423 if (!(conf & TX39_CONF_DCE))
424 printk("TX3927 D-Cache disabled.\n");
425 else if (!(conf & TX39_CONF_WBON))
426 printk("TX3927 D-Cache WriteThrough.\n");
427 else if (!(conf & TX39_CONF_CWFON))
428 printk("TX3927 D-Cache WriteBack.\n");
429 else
430 printk("TX3927 D-Cache WriteBack (CWF) .\n");
431 }
432}
Atsushi Nemotoa0574e02007-03-01 00:40:21 +0900433
434/* This trick makes rtc-ds1742 driver usable as is. */
435unsigned long __swizzle_addr_b(unsigned long port)
436{
437 if ((port & 0xffff0000) != JMR3927_IOC_NVRAMB_ADDR)
438 return port;
439 port = (port & 0xffff0000) | (port & 0x7fff << 1);
440#ifdef __BIG_ENDIAN
441 return port;
442#else
443 return port | 1;
444#endif
445}
446EXPORT_SYMBOL(__swizzle_addr_b);
447
448static int __init jmr3927_rtc_init(void)
449{
Atsushi Nemoto4614c322007-05-01 01:49:20 +0900450 static struct resource __initdata res = {
Atsushi Nemotoa0574e02007-03-01 00:40:21 +0900451 .start = JMR3927_IOC_NVRAMB_ADDR - IO_BASE,
452 .end = JMR3927_IOC_NVRAMB_ADDR - IO_BASE + 0x800 - 1,
453 .flags = IORESOURCE_MEM,
454 };
455 struct platform_device *dev;
Atsushi Nemotoa95e23a2007-10-16 01:28:18 -0700456 dev = platform_device_register_simple("rtc-ds1742", -1, &res, 1);
Atsushi Nemotoa0574e02007-03-01 00:40:21 +0900457 return IS_ERR(dev) ? PTR_ERR(dev) : 0;
458}
459device_initcall(jmr3927_rtc_init);