2 +++ b/arch/mips/lantiq/falcon/Kconfig
8 +config LANTIQ_MACH_EASY98000
16 +++ b/arch/mips/lantiq/falcon/Makefile
18 +obj-y := clk-falcon.o devices.o gpio.o prom.o sysctrl.o reset.o
19 +obj-y += softdog_vpe.o
20 +obj-$(CONFIG_LANTIQ_MACH_EASY98000) += mach-easy98000.o
22 +++ b/arch/mips/lantiq/falcon/clk-falcon.c
25 + * This program is free software; you can redistribute it and/or modify
26 + * it under the terms of the GNU General Public License as published by
27 + * the Free Software Foundation; either version 2 of the License, or
28 + * (at your option) any later version.
30 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
33 +#include <linux/io.h>
34 +#include <linux/module.h>
35 +#include <linux/init.h>
37 +#include <asm/time.h>
39 +#include <asm/div64.h>
43 +#include <falcon/sys1_reg.h>
45 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
48 +lq_get_io_region_clock(void)
50 + return 200000000; /* 200 MHz */
52 +EXPORT_SYMBOL(lq_get_io_region_clock);
57 + if ((lq_r32(&pSYS1->cpu0cc) & CPU0CC_CPUDIV) == CPU0CC_CPUDIV_SELFHALF)
58 + return 200000000; /* 200 MHz */
60 + return 400000000; /* 400 MHz */
62 +EXPORT_SYMBOL(lq_get_cpu_hz);
69 +EXPORT_SYMBOL(lq_get_fpi_hz);
71 +++ b/arch/mips/lantiq/falcon/devices.c
73 +#include <linux/init.h>
74 +#include <linux/module.h>
75 +#include <linux/types.h>
76 +#include <linux/string.h>
77 +#include <linux/mtd/physmap.h>
78 +#include <linux/kernel.h>
79 +#include <linux/reboot.h>
80 +#include <linux/platform_device.h>
81 +#include <linux/leds.h>
82 +#include <linux/etherdevice.h>
83 +#include <linux/reboot.h>
84 +#include <linux/time.h>
85 +#include <linux/io.h>
86 +#include <linux/gpio.h>
87 +#include <linux/leds.h>
88 +#include <linux/spi/spi.h>
90 +#include <asm/bootinfo.h>
95 +#include <falcon/falcon_irq.h>
96 +#include <falcon/gpon_reg_base.h>
97 +#include <falcon/sys1_reg.h>
98 +#include <falcon/sys_eth_reg.h>
100 +#include <falcon/sysctrl.h>
102 +#include "devices.h"
104 +unsigned char lq_ethaddr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
105 +EXPORT_SYMBOL(lq_ethaddr);
108 +falcon_set_ethaddr(char *str)
110 + sscanf(str, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
111 + &lq_ethaddr[0], &lq_ethaddr[1], &lq_ethaddr[2],
112 + &lq_ethaddr[3], &lq_ethaddr[4], &lq_ethaddr[5]);
115 +__setup("ethaddr=", falcon_set_ethaddr);
118 +static struct resource falcon_asc0_resources[] =
120 + MEM_RES("asc0",GPON_ASC0_BASE,GPON_ASC0_END),
121 + IRQ_RES("tx",INT_NUM_IM3_IRL0),
122 + IRQ_RES("rx",INT_NUM_IM3_IRL0+1),
123 + IRQ_RES("err",INT_NUM_IM3_IRL0+2),
126 +static struct resource falcon_asc1_resources[] =
128 + MEM_RES("asc1",GPON_ASC1_BASE,GPON_ASC1_END),
129 + IRQ_RES("tx",INT_NUM_IM3_IRL0+8),
130 + IRQ_RES("rx",INT_NUM_IM3_IRL0+9),
131 + IRQ_RES("err",INT_NUM_IM3_IRL0+10),
134 +void __init falcon_register_asc(int port)
138 + platform_device_register_simple("lq_asc", 0,
139 + falcon_asc0_resources, ARRAY_SIZE(falcon_asc0_resources));
142 + platform_device_register_simple("lq_asc", 1,
143 + falcon_asc1_resources, ARRAY_SIZE(falcon_asc1_resources));
151 +static struct resource lq_nor_resource =
152 + MEM_RES("nor",LQ_FLASH_START,LQ_FLASH_START + LQ_FLASH_MAX - 1);
154 +static struct platform_device lq_nor = {
156 + .resource = &lq_nor_resource,
157 + .num_resources = 1,
160 +void __init falcon_register_nor(struct physmap_flash_data *data)
162 + lq_nor.dev.platform_data = data;
163 + platform_device_register(&lq_nor);
167 +static struct resource lq_spi_resources[] = {
168 + MEM_RES("ebu", GPON_EBU_BASE, GPON_EBU_END),
169 + MEM_RES("sys1", GPON_SYS1_BASE, GPON_SYS1_END)
172 +static struct platform_device lq_spi = {
173 + .name = "falcon_spi",
174 + .resource = lq_spi_resources,
175 + .num_resources = ARRAY_SIZE(lq_spi_resources)
178 +void __init falcon_register_spi_flash(struct spi_board_info *data)
180 + spi_register_board_info(data, 1);
181 + platform_device_register(&lq_spi);
185 +static struct resource falcon_wdt_resource =
186 + MEM_RES("watchdog",GPON_WDT_BASE,GPON_WDT_END);
188 +void __init falcon_register_wdt(void)
190 + platform_device_register_simple("lq_wdt", 0, &falcon_wdt_resource, 1);
194 +#define DECLARE_GPIO_RES(port) \
195 +static struct resource falcon_gpio ## port ## _resources[] = { \
196 + MEM_RES("gpio"#port,GPON_GPIO ## port ## _BASE,GPON_GPIO ## port ## _END), \
197 + MEM_RES("padctrl"#port,GPON_PADCTRL ## port ## _BASE,GPON_PADCTRL ## port ## _END), \
198 + IRQ_RES("gpio_mux"#port,FALCON_IRQ_GPIO_P ## port ) \
200 +DECLARE_GPIO_RES(0);
201 +DECLARE_GPIO_RES(1);
202 +DECLARE_GPIO_RES(2);
203 +#ifdef REGISTER_ALL_GPIO_PORTS
205 +#error NR_IRQS to low for all gpio irqs
207 +DECLARE_GPIO_RES(3);
208 +DECLARE_GPIO_RES(4);
211 +void __init falcon_register_gpio(void)
213 + platform_device_register_simple("falcon_gpio", 0,
214 + falcon_gpio0_resources, ARRAY_SIZE(falcon_gpio0_resources));
215 + platform_device_register_simple("falcon_gpio", 1,
216 + falcon_gpio1_resources, ARRAY_SIZE(falcon_gpio1_resources));
217 + platform_device_register_simple("falcon_gpio", 2,
218 + falcon_gpio2_resources, ARRAY_SIZE(falcon_gpio2_resources));
219 + sys1_hw_activate(ACTS_PADCTRL1 | ACTS_P1);
220 + sys_eth_hw_activate(SYS_ETH_ACTS_PADCTRL0 | SYS_ETH_ACTS_PADCTRL2 |
221 + SYS_ETH_ACTS_P0 | SYS_ETH_ACTS_P2);
223 +#ifdef REGISTER_ALL_GPIO_PORTS
224 + /* optional gpio ports: not registered,
225 + as the pins are EBU specific and always used by linux */
226 + platform_device_register_simple("falcon_gpio", 3,
227 + falcon_gpio3_resources, ARRAY_SIZE(falcon_gpio3_resources));
228 + platform_device_register_simple("falcon_gpio", 4,
229 + falcon_gpio4_resources, ARRAY_SIZE(falcon_gpio4_resources));
230 + sys1_hw_activate(ACTS_PADCTRL3 | ACTS_PADCTRL4 | ACTS_P3 | ACTS_P4);
234 +static struct resource falcon_i2c_resources[] = {
235 + MEM_RES("i2c", GPON_I2C_BASE,GPON_I2C_END),
236 + IRQ_RES("i2c_lb", FALCON_IRQ_I2C_LBREQ),
237 + IRQ_RES("i2c_b", FALCON_IRQ_I2C_BREQ),
238 + IRQ_RES("i2c_err", FALCON_IRQ_I2C_I2C_ERR),
239 + IRQ_RES("i2c_p", FALCON_IRQ_I2C_I2C_P),
242 +void __init falcon_register_i2c(void)
244 + platform_device_register_simple("i2c-falcon", 0,
245 + falcon_i2c_resources, ARRAY_SIZE(falcon_i2c_resources));
246 + sys1_hw_activate(ACTS_I2C_ACT);
249 +void __init falcon_register_crypto(void)
251 + platform_device_register_simple("lq_falcon_deu", 0, NULL, 0);
254 +++ b/arch/mips/lantiq/falcon/devices.h
256 +#ifndef _FALCON_DEVICES_H__
257 +#define _FALCON_DEVICES_H__
259 +#include <linux/mtd/physmap.h>
260 +#include <linux/spi/spi.h>
261 +#include <linux/spi/flash.h>
263 +extern void __init falcon_register_asc(int port);
264 +extern void __init falcon_register_i2c(void);
265 +extern void __init falcon_register_spi_flash(struct spi_board_info *data);
266 +extern void __init falcon_register_gpio(void);
267 +extern void __init falcon_register_nor(struct physmap_flash_data *data);
268 +extern void __init falcon_register_wdt(void);
269 +extern void __init falcon_register_crypto(void);
271 +#define IRQ_RES(resname,irq) {.name=resname,.start=(irq),.flags=IORESOURCE_IRQ}
272 +#define MEM_RES(resname,adr_start,adr_end) \
273 + { .name=resname, .flags=IORESOURCE_MEM, \
274 + .start=((adr_start)&~KSEG1),.end=((adr_end)&~KSEG1) }
278 +++ b/arch/mips/lantiq/falcon/prom.c
281 + * This program is free software; you can redistribute it and/or modify
282 + * it under the terms of the GNU General Public License as published by
283 + * the Free Software Foundation; either version 2 of the License, or
284 + * (at your option) any later version.
286 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
289 +#include <linux/module.h>
290 +#include <linux/clk.h>
291 +#include <asm/bootinfo.h>
292 +#include <asm/time.h>
296 +#include <falcon/gpon_reg_base.h>
297 +#include <falcon/status_reg.h>
298 +#include <falcon/sys1_reg.h>
300 +#include "../prom.h"
302 +static struct gpon_reg_status * const pSTATUS = (struct gpon_reg_status *)GPON_STATUS_BASE;
304 +#define SOC_FALCON "Falcon"
307 +lq_soc_detect(struct lq_soc_info *i)
309 + i->partnum = (lq_r32(&pSTATUS->chipid) & STATUS_CHIPID_PARTNR_MASK) >> STATUS_CHIPID_PARTNR_OFFSET;
310 + i->rev = (lq_r32(&pSTATUS->chipid) & STATUS_CHIPID_VERSION_MASK) >> STATUS_CHIPID_VERSION_OFFSET;
311 + switch (i->partnum)
313 + case SOC_ID_FALCON:
314 + i->name = SOC_FALCON;
315 + i->type = SOC_TYPE_FALCON;
319 + printk(KERN_ERR "unknown partnum : 0x%08X\n", i->partnum);
325 +++ b/arch/mips/lantiq/falcon/sysctrl.c
328 + * This program is free software; you can redistribute it and/or
329 + * modify it under the terms of the GNU General Public License as
330 + * published by the Free Software Foundation; either version 2 of
331 + * the License, or (at your option) any later version.
333 + * This program is distributed in the hope that it will be useful,
334 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
335 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
336 + * GNU General Public License for more details.
338 + * You should have received a copy of the GNU General Public License
339 + * along with this program; if not, write to the Free Software
340 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
341 + * MA 02111-1307 USA
343 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
346 +#include <linux/cpu.h>
347 +#include <linux/init.h>
348 +#include <linux/kernel.h>
349 +#include <linux/pm.h>
350 +#include <linux/io.h>
351 +#include <linux/ioport.h>
352 +#include <linux/clk.h>
353 +#include <asm/reboot.h>
355 +#include <falcon/gpon_reg_base.h>
356 +#include <falcon/status_reg.h>
357 +#include <falcon/sys1_reg.h>
358 +#include <falcon/sys_eth_reg.h>
359 +#include <falcon/sys_gpe_reg.h>
361 +#include <falcon/sysctrl.h>
363 +/* mapping to linux hw-accessor routines */
364 +#define reg_r32(reg) __raw_readl(reg)
365 +#define reg_w32(val, reg) __raw_writel(val, reg)
366 +#define reg_w32_mask(clear, set, reg) reg_w32((reg_r32(reg) & ~(clear)) | (set), reg)
368 +static struct gpon_reg_sys1 * const sys1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
369 +static struct gpon_reg_sys_eth * const sys_eth = (struct gpon_reg_sys_eth *)GPON_SYS_ETH_BASE;
370 +static struct gpon_reg_sys_gpe * const sys_gpe = (struct gpon_reg_sys_gpe *)GPON_SYS_GPE_BASE;
371 +static struct gpon_reg_status * const status = (struct gpon_reg_status *)GPON_STATUS_BASE;
374 + * Activate the selected module(s)
375 + * Enables the clock of the module and activates the module itself.
377 + * \param[in] mask bitmask of module(s), as for registers SYS1.ACT
380 +void sys1_hw_activate(u32 mask)
382 + sys1_w32(mask, clken);
383 + sys1_w32(mask, act);
385 + while ( (sys1_r32(acts) & mask) != mask) {
389 +EXPORT_SYMBOL(sys1_hw_activate);
392 + * Deactivate the selected module(s)
393 + * Disables the clock of the module and deactivates the module itself.
395 + * \param[in] mask bitmask of module(s), as for registers SYS1.DEACT
398 +void sys1_hw_deactivate(u32 mask)
400 + sys1_w32(mask, clkclr);
401 + sys1_w32(mask, deact);
403 + while ( (sys1_r32(acts) & mask) != 0) {
407 +EXPORT_SYMBOL(sys1_hw_deactivate);
410 + * Clock enable for the selected module(s)
411 + * Enables the clock of the module.
413 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKEN
416 +void sys1_hw_clk_enable(u32 mask)
418 + sys1_w32(mask, clken);
420 + while ( (sys1_r32(clks) & mask) != mask) {
424 +EXPORT_SYMBOL(sys1_hw_clk_enable);
427 + * Clock disable for the selected module(s)
428 + * disables the clock of the module.
430 + * \param[in] mask bitmask of module(s), as for registers SYS1.CLKCLR
433 +void sys1_hw_clk_disable(u32 mask)
435 + sys1_w32(mask, clkclr);
437 + while ( (sys1_r32(clks) & mask) != 0) {
441 +EXPORT_SYMBOL(sys1_hw_clk_disable);
444 + * Reboots the selected module(s)
445 + * Triggers the reboot of the module.
447 + * \param[in] mask bitmask of module(s), as for registers SYS1.RBT
450 +void sys1_hw_activate_or_reboot(u32 mask)
452 + u32 acts = sys1_r32(acts);
453 + /* is not already active? */
454 + if ((~acts & mask) != 0)
455 + sys1_hw_activate(~acts & mask);
456 + sys1_w32(acts & mask, rbt);
457 + while ( (sys1_r32(acts) & mask) != mask) {
461 +EXPORT_SYMBOL(sys1_hw_activate_or_reboot);
464 + * Activate the selected module(s)
465 + * Enables the clock of the module and activates the module itself.
467 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.ACT
470 +void sys_eth_hw_activate(u32 mask)
472 + sys_eth_w32(mask, clken);
473 + sys_eth_w32(mask, act);
475 + while ( (sys_eth_r32(acts) & mask) != mask) {
479 +EXPORT_SYMBOL(sys_eth_hw_activate);
482 + * Deactivate the selected module(s)
483 + * Disables the clock of the module and deactivates the module itself.
485 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.DEACT
488 +void sys_eth_hw_deactivate(u32 mask)
490 + sys_eth_w32(mask, clkclr);
491 + sys_eth_w32(mask, deact);
493 + while ( (sys_eth_r32(acts) & mask) != 0) {
497 +EXPORT_SYMBOL(sys_eth_hw_deactivate);
500 + * Clock enable for the selected module(s)
501 + * Enables the clock of the module.
503 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKEN
506 +void sys_eth_hw_clk_enable(u32 mask)
508 + sys_eth_w32(mask, clken);
510 + while ( (sys_eth_r32(clks) & mask) != mask) {
514 +EXPORT_SYMBOL(sys_eth_hw_clk_enable);
517 + * Clock disable for the selected module(s)
518 + * disables the clock of the module.
520 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.CLKCLR
523 +void sys_eth_hw_clk_disable(u32 mask)
525 + sys_eth_w32(mask, clkclr);
527 + while ( (sys_eth_r32(clks) & mask) != 0) {
531 +EXPORT_SYMBOL(sys_eth_hw_clk_disable);
534 + * Reboots the selected module(s)
535 + * Triggers the reboot of the module.
537 + * \param[in] mask bitmask of module(s), as for registers SYS_ETH.RBT
540 +void sys_eth_hw_activate_or_reboot(u32 mask)
542 + u32 acts = sys_eth_r32(acts);
543 + /* is not already active? */
544 + if ((~acts & mask) != 0)
545 + sys_eth_hw_activate(~acts & mask);
546 + sys_eth_w32(acts & mask, rbt);
547 + while ( (sys_eth_r32(acts) & mask) != mask) {
551 +EXPORT_SYMBOL(sys_eth_hw_activate_or_reboot);
553 +static int gpe_clk_is_enabled(void)
557 + rd_data = sys1_r32(infrac);
558 + if (rd_data & (1<<(INFRAC_GP_OFFSET+1)))
563 +static void enable_gpe_clk(void)
567 + u32 rd_data_to_keep;
570 + if (gpe_clk_is_enabled())
571 + /* clock already active, no need to change here */
574 + if (status_r32(config) == 0)
575 + aeFreq = 1; /* use 625MHz on unfused chip */
577 + aeFreq = (status_r32(config) & STATUS_CONFIG_GPEFREQ_MASK) >> STATUS_CONFIG_GPEFREQ_OFFSET;
578 + rd_data = sys1_r32(infrac);
579 + /* clear gpe-fsel and enable bits */
580 + rd_data_to_keep = rd_data & ~(7<<(INFRAC_GP_OFFSET+1));
583 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)), infrac);
585 + for (i = 0; i <10; i++) /* wait 10 cycles */
588 + /* keep new fsel and enable */
589 + sys1_w32(rd_data_to_keep | (aeFreq<<(INFRAC_GP_OFFSET+2)) |
590 + (1<<(INFRAC_GP_OFFSET+1)), infrac);
591 + for (i = 0; i <100; i++) /* wait 100 cycles */
596 + * Activate the selected module(s)
597 + * Enables the clock of the module and activates the module itself.
599 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.ACT
602 +void sys_gpe_hw_activate(u32 mask)
605 + sys_gpe_w32(mask, clken);
606 + sys_gpe_w32(mask, act);
608 + while ( (sys_gpe_r32(acts) & mask) != mask) {
612 +EXPORT_SYMBOL(sys_gpe_hw_activate);
615 + * Deactivate the selected module(s)
616 + * Disables the clock of the module and deactivates the module itself.
618 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.DEACT
621 +void sys_gpe_hw_deactivate(u32 mask)
624 + sys_gpe_w32(mask, clkclr);
625 + sys_gpe_w32(mask, deact);
627 + while ( (sys_gpe_r32(acts) & mask) != 0) {
631 +EXPORT_SYMBOL(sys_gpe_hw_deactivate);
634 + * Clock enable for the selected module(s)
635 + * Enables the clock of the module.
637 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKEN
640 +void sys_gpe_hw_clk_enable(u32 mask)
643 + sys_gpe_w32(mask, clken);
645 + while ( (sys_gpe_r32(clks) & mask) != mask) {
649 +EXPORT_SYMBOL(sys_gpe_hw_clk_enable);
652 + * Clock disable for the selected module(s)
653 + * disables the clock of the module.
655 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.CLKCLR
658 +void sys_gpe_hw_clk_disable(u32 mask)
661 + sys_gpe_w32(mask, clkclr);
663 + while ( (sys_gpe_r32(clks) & mask) != 0) {
667 +EXPORT_SYMBOL(sys_gpe_hw_clk_disable);
670 + * Reboots the selected module(s)
671 + * Triggers the reboot of the module.
673 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
676 +void sys_gpe_hw_activate_or_reboot(u32 mask)
680 + acts = sys_gpe_r32(acts);
681 + /* is not already active? */
682 + if ((~acts & mask) != 0)
683 + sys_gpe_hw_activate(~acts & mask);
684 + sys_gpe_w32(acts & mask, rbt);
685 + while ( (sys_gpe_r32(acts) & mask) != mask) {
689 +EXPORT_SYMBOL(sys_gpe_hw_activate_or_reboot);
692 + * Retrieve activation status of the selected hardware module(s)
694 + * \param[in] mask bitmask of module(s), as for registers SYS_GPE.RBT
695 + * \return int 1 - if hardware module(s) is activated (including clock)
697 + int sys_gpe_hw_is_activated(u32 mask)
699 + if (gpe_clk_is_enabled() == 0)
702 + if ((sys_gpe_r32(clks) & mask) != mask)
705 + return ((sys_gpe_r32(acts) & mask) == mask);
707 +EXPORT_SYMBOL(sys_gpe_hw_is_activated);
709 +++ b/arch/mips/lantiq/falcon/gpio.c
712 + * This program is free software; you can redistribute it and/or modify
713 + * it under the terms of the GNU General Public License as published by
714 + * the Free Software Foundation; either version 2 of the License, or
715 + * (at your option) any later version.
717 + * This program is distributed in the hope that it will be useful,
718 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
719 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
720 + * GNU General Public License for more details.
722 + * You should have received a copy of the GNU General Public License
723 + * along with this program; if not, write to the Free Software
724 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
726 + * Copyright (C) 2010 Thomas Langer, Lantiq Deutschland
732 + - provide mask of available pins per platform_data
735 +#include <linux/module.h>
736 +#include <linux/types.h>
737 +#include <linux/errno.h>
738 +#include <linux/init.h>
739 +#include <linux/seq_file.h>
740 +#include <linux/platform_device.h>
741 +#include <linux/uaccess.h>
742 +#include <linux/gpio.h>
743 +#include <linux/irq.h>
744 +#include <linux/interrupt.h>
745 +#include <linux/slab.h>
748 +#include <falcon/falcon_irq.h>
750 +#include <linux/version.h>
751 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
752 +#define for_each_set_bit for_each_bit
755 +#define gpio_r32(reg) __raw_readl(reg)
756 +#define gpio_w32(val, reg) __raw_writel(val, reg)
757 +#define gpio_w32_mask(clear, set, reg) gpio_w32((gpio_r32(reg) & ~(clear)) | (set), reg)
760 +/** register structure for padctrl
761 + (mainly needed for mux control) */
762 +typedef struct gpon_padctrl_s
764 + /** Multiplexer Control Register
765 + The value 0 (the reset-value) is always the default function corresponding to the pad's name. The value 1 selects always the GPIO functionality (if available). */
766 + unsigned int muxc[32];
767 + /** Pull Up Enable Register */
768 + unsigned int puen; /* 0x00000080 */
769 + /** Pull Down Enable Register */
770 + unsigned int pden; /* 0x00000084 */
771 + /** Slew Rate Control Register */
772 + unsigned int src; /* 0x00000088 */
773 + /** Drive Current Control Register */
774 + unsigned int dcc; /* 0x0000008C */
776 + unsigned int res_0[24]; /* 0x00000090 */
777 + /** Pad Control Availability Register */
778 + unsigned int avail; /* 0x000000F0 */
781 +/** register structure for gpio port */
782 +typedef struct gpon_gpio_s
784 + /** Data Output Register
785 + Via this register the output values of the different bits can be set if they are switched as outputs. */
786 + unsigned int out; /* 0x00000000 */
787 + /** Data Input Register
788 + Via this register the input values of the different bits can be observed. */
789 + unsigned int in; /* 0x00000004 */
790 + /** Direction Register
791 + Via this register the input direction of the different bits can be determined. */
792 + unsigned int dir; /* 0x00000008 */
794 + unsigned int res_0[3]; /* 0x0000000C */
795 + /** External Interrupt Control Register 0 */
796 + unsigned int exintcr0; /* 0x00000018 */
797 + /** External Interrupt Control Register 1 */
798 + unsigned int exintcr1; /* 0x0000001C */
799 + /** IRN Capture Register
800 + This register shows the currently active interrupt events masked with the corresponding enable bits of the IRNEN register. The interrupts can be acknowledged by a write operation. */
801 + unsigned int irncr; /* 0x00000020 */
802 + /** IRN Interrupt Control Register
803 + A write operation directly effects the interrupts. This can be used to trigger events under software control for testing purposes. A read operation returns the unmasked interrupt events. */
804 + unsigned int irnicr; /* 0x00000024 */
805 + /** IRN Interrupt Enable Register
806 + This register contains the enable (or mask) bits for the interrupts. Disabled interrupts are not visible in the IRNCR register and are not signalled via the interrupt line towards the controller. */
807 + unsigned int irnen; /* 0x00000028 */
808 + /** IRN Interrupt Configuration Register
809 + Configures the interrupts bitwise to be edge-senstivie or level-sensitive. */
810 + unsigned int irncfg; /* 0x0000002C */
811 + /** IRN Interrupt Enable Set Register
812 + The corresponding bit in the IRNEN register can be set with an atomic access. */
813 + unsigned int irnenset; /* 0x00000030 */
814 + /** IRN Interrupt Enable Clear Register
815 + The corresponding bit in the IRNEN register can be cleared with an atomic access. */
816 + unsigned int irnenclr; /* 0x00000034 */
818 + unsigned int res_1[2]; /* 0x00000038 */
819 + /** Output Set Register
820 + This register can be used to set certain bits within the OUT register without touching the other bits. */
821 + unsigned int outset; /* 0x00000040 */
822 + /** Output Clear Register
823 + This register can be used to clear certain bits within the OUT register without touching the other bits. */
824 + unsigned int outclr; /* 0x00000044 */
825 + /** Direction Set Register
826 + This register can be used to set certain bits within the DIR register without touching the other bits. */
827 + unsigned int dirset; /* 0x00000048 */
828 + /** Direction Clear Register
829 + This register can be used to clear certain bits within the DIR register without touching the other bits. */
830 + unsigned int dirclr; /* 0x0000004C */
833 +struct falcon_gpio_port {
834 + struct gpio_chip gpio_chip;
835 + gpon_padctrl0_t __iomem *pad;
836 + gpon_gpio_t __iomem *port;
837 + struct resource *pad_req; /* resources requested */
838 + struct resource *port_req;
839 + unsigned int irq_base;
840 + unsigned int chained_irq;
843 +static int gpio_exported = 0;
844 +static int __init gpio_export_setup(char *str)
846 + get_option(&str, &gpio_exported);
849 +__setup("gpio_exported=", gpio_export_setup);
851 +static inline struct falcon_gpio_port *to_falcon_gpio_port(struct gpio_chip *chip)
853 + return container_of(chip, struct falcon_gpio_port, gpio_chip);
856 +static int falcon_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
858 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
859 + gpio_w32(1<<offset, &gpio_port->port->dirclr);
863 +static int falcon_gpio_direction_output(struct gpio_chip *chip, unsigned int offset, int value)
865 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
866 + gpio_w32(1<<offset, &gpio_port->port->dirset);
870 +static void falcon_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
872 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
874 + gpio_w32(1<<offset, &gpio_port->port->outset);
876 + gpio_w32(1<<offset, &gpio_port->port->outclr);
879 +static int falcon_gpio_get(struct gpio_chip *chip, unsigned int offset)
881 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
882 + if ((gpio_r32(&gpio_port->port->dir) >> offset) & 1)
883 + return (gpio_r32(&gpio_port->port->out) >> offset) & 1;
885 + return (gpio_r32(&gpio_port->port->in) >> offset) & 1;
888 +static int falcon_gpio_request(struct gpio_chip *chip, unsigned offset)
890 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
891 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
892 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
894 + /* switch on gpio function */
895 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
902 +static void falcon_gpio_free(struct gpio_chip *chip, unsigned offset)
904 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
905 + if ( (gpio_r32(&gpio_port->pad->avail) >> offset) & 1) {
906 + if (gpio_r32(&gpio_port->pad->muxc[offset]) > 1)
908 + /* switch off gpio function */
909 + gpio_w32(0, &gpio_port->pad->muxc[offset]);
913 +static int falcon_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
915 + struct falcon_gpio_port *gpio_port = to_falcon_gpio_port(chip);
916 + /* no checks: this functions is only registered with valid irq_base */
917 + return gpio_port->irq_base + offset;
920 +static void falcon_gpio_disable_irq(unsigned int irq)
922 + struct falcon_gpio_port *gpio_port = get_irq_chip_data(irq);
923 + unsigned int offset = irq-gpio_port->irq_base;
924 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
927 +static void falcon_gpio_enable_irq(unsigned int irq)
929 + struct falcon_gpio_port *gpio_port = get_irq_chip_data(irq);
930 + unsigned int offset = irq-gpio_port->irq_base;
932 + if (gpio_r32(&gpio_port->pad->muxc[offset]) < 1) {
933 + /* switch on gpio function */
934 + gpio_w32(1, &gpio_port->pad->muxc[offset]);
937 + gpio_w32(1<<offset, &gpio_port->port->irnenset);
940 +static void falcon_gpio_ack_irq(unsigned int irq)
942 + struct falcon_gpio_port *gpio_port = get_irq_chip_data(irq);
943 + unsigned int offset = irq-gpio_port->irq_base;
944 + gpio_w32(1<<offset, &gpio_port->port->irncr);
947 +static void falcon_gpio_mask_and_ack_irq(unsigned int irq)
949 + struct falcon_gpio_port *gpio_port = get_irq_chip_data(irq);
950 + unsigned int offset = irq-gpio_port->irq_base;
951 + gpio_w32(1<<offset, &gpio_port->port->irnenclr);
952 + gpio_w32(1<<offset, &gpio_port->port->irncr);
955 +static struct irq_chip falcon_gpio_irq_chip;
956 +static int falcon_gpio_irq_type(unsigned irq, unsigned int type)
958 + struct falcon_gpio_port *gpio_port = get_irq_chip_data(irq);
959 + unsigned int offset = irq-gpio_port->irq_base;
960 + unsigned int mask = 1 << offset;
962 + if ((type & IRQ_TYPE_SENSE_MASK) == IRQ_TYPE_NONE)
965 + if ((type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) != 0) {
966 + /* level triggered */
967 + gpio_w32_mask(0, mask, &gpio_port->port->irncfg);
968 + set_irq_chip_and_handler_name(irq,
969 + &falcon_gpio_irq_chip, handle_level_irq, "mux");
971 + /* edge triggered */
972 + gpio_w32_mask(mask, 0, &gpio_port->port->irncfg);
973 + set_irq_chip_and_handler_name(irq,
974 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
977 + if ((type & IRQ_TYPE_EDGE_BOTH) == IRQ_TYPE_EDGE_BOTH) {
978 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
979 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr1);
981 + if ((type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_LEVEL_HIGH)) != 0) {
982 + /* positive logic: rising edge, high level */
983 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr0);
985 + /* negative logic: falling edge, low level */
986 + gpio_w32_mask(0, mask, &gpio_port->port->exintcr0);
988 + gpio_w32_mask(mask, 0, &gpio_port->port->exintcr1);
991 + return gpio_direction_input(gpio_port->gpio_chip.base + offset);
994 +static void falcon_gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
996 + struct falcon_gpio_port *gpio_port = get_irq_desc_data(desc);
997 + unsigned long irncr;
1000 + irncr = gpio_r32(&gpio_port->port->irncr);
1001 + /* acknowledge interrupt */
1002 + gpio_w32(irncr, &gpio_port->port->irncr);
1004 + desc->chip->ack(irq);
1006 + for_each_set_bit(offset, &irncr, gpio_port->gpio_chip.ngpio)
1007 + generic_handle_irq(gpio_port->irq_base + offset);
1010 +static struct irq_chip falcon_gpio_irq_chip = {
1011 + .name = "gpio_irq_mux",
1012 + .mask = falcon_gpio_disable_irq,
1013 + .unmask = falcon_gpio_enable_irq,
1014 + .ack = falcon_gpio_ack_irq,
1015 + .mask_ack = falcon_gpio_mask_and_ack_irq,
1016 + .set_type = falcon_gpio_irq_type,
1019 +static struct irqaction gpio_cascade = {
1020 + .handler = no_action,
1021 + .flags = IRQF_DISABLED,
1022 + .name = "gpio_cascade",
1025 +static int falcon_gpio_probe(struct platform_device *pdev)
1027 + struct falcon_gpio_port *gpio_port;
1029 + struct resource *gpiores, *padres;
1032 + gpiores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1033 + padres = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1034 + irq = platform_get_irq(pdev, 0);
1035 + if (!gpiores || !padres)
1038 + gpio_port = kzalloc(sizeof(*gpio_port), GFP_KERNEL);
1039 + if (gpio_port == NULL)
1042 + gpio_port->gpio_chip.label = "falcon-gpio";
1043 + gpio_port->gpio_chip.direction_input = falcon_gpio_direction_input;
1044 + gpio_port->gpio_chip.direction_output = falcon_gpio_direction_output;
1045 + gpio_port->gpio_chip.get = falcon_gpio_get;
1046 + gpio_port->gpio_chip.set = falcon_gpio_set;
1047 + gpio_port->gpio_chip.request = falcon_gpio_request;
1048 + gpio_port->gpio_chip.free = falcon_gpio_free;
1049 + gpio_port->gpio_chip.base = 100 * pdev->id;
1050 + gpio_port->gpio_chip.ngpio = 32;
1051 + gpio_port->gpio_chip.dev = &pdev->dev;
1052 + gpio_port->gpio_chip.exported = gpio_exported;
1054 + gpio_port->port_req = request_mem_region(gpiores->start,
1055 + resource_size(gpiores), pdev->name);
1056 + gpio_port->pad_req = request_mem_region(padres->start,
1057 + resource_size(padres), pdev->name);
1058 + if (!gpio_port->port_req || !gpio_port->pad_req) {
1059 + dev_err(&pdev->dev, "cannot claim register area\n");
1064 + gpio_port->port = ioremap_nocache(gpiores->start,
1065 + resource_size(gpiores));
1066 + gpio_port->pad = ioremap_nocache(padres->start,
1067 + resource_size(padres));
1068 + if (!gpio_port->port || !gpio_port->pad) {
1069 + dev_err(&pdev->dev, "Could not map io ranges\n");
1076 + * irq_chip support
1078 + gpio_port->gpio_chip.to_irq = falcon_gpio_to_irq;
1079 + gpio_port->irq_base = INT_NUM_EXTRA_START + 32 * pdev->id;
1081 + for (i = 0; i < 32; i++) {
1082 + set_irq_chip_and_handler_name(gpio_port->irq_base + i,
1083 + &falcon_gpio_irq_chip, handle_simple_irq, "mux");
1084 + set_irq_chip_data(gpio_port->irq_base + i, gpio_port);
1085 + /* FIXME: set default cfg to level triggered */
1086 + //gpio_w32_mask(0, 1<<i, &gpio_port->port->irncfg);
1087 + /* set to negative logic (falling edge, low level) */
1088 + gpio_w32_mask(0, 1<<i, &gpio_port->port->exintcr0);
1091 + gpio_port->chained_irq = irq;
1092 + setup_irq(irq, &gpio_cascade);
1093 + set_irq_data(irq, gpio_port);
1094 + set_irq_chained_handler(irq, falcon_gpio_irq_handler);
1097 + ret = gpiochip_add(&gpio_port->gpio_chip);
1099 + dev_err(&pdev->dev, "Could not register gpiochip %d, %d\n",
1103 + platform_set_drvdata(pdev, gpio_port);
1107 + dev_err(&pdev->dev, "Error in gpio_probe %d, %d\n", pdev->id, ret);
1108 + if (gpio_port->port_req)
1109 + release_resource(gpio_port->port_req);
1110 + if (gpio_port->pad_req)
1111 + release_resource(gpio_port->pad_req);
1113 + if (gpio_port->port)
1114 + iounmap(gpio_port->port);
1115 + if (gpio_port->pad)
1116 + iounmap(gpio_port->pad);
1121 +static int falcon_gpio_remove(struct platform_device *pdev)
1123 + struct falcon_gpio_port *gpio_port = platform_get_drvdata(pdev);
1126 + ret = gpiochip_remove(&gpio_port->gpio_chip);
1127 + if (gpio_port->port_req)
1128 + release_resource(gpio_port->port_req);
1129 + if (gpio_port->pad_req)
1130 + release_resource(gpio_port->pad_req);
1131 + if (gpio_port->port)
1132 + iounmap(gpio_port->port);
1133 + if (gpio_port->pad)
1134 + iounmap(gpio_port->pad);
1141 +static struct platform_driver falcon_gpio_driver = {
1142 + .probe = falcon_gpio_probe,
1143 + .remove = __devexit_p(falcon_gpio_remove),
1145 + .name = "falcon_gpio",
1146 + .owner = THIS_MODULE,
1150 +int __init falcon_gpio_init(void)
1154 + printk(KERN_INFO "FALC(tm) ON GPIO Driver, (C) 2011 Lantiq Deutschland Gmbh\n");
1155 + ret = platform_driver_register(&falcon_gpio_driver);
1157 + pr_err( "falcon_gpio: Error registering platform driver!");
1161 +void __exit falcon_gpio_exit(void)
1163 + platform_driver_unregister(&falcon_gpio_driver);
1166 +int gpio_to_irq(unsigned int gpio)
1168 + return __gpio_to_irq(gpio);
1170 +EXPORT_SYMBOL(gpio_to_irq);
1172 +module_init(falcon_gpio_init);
1173 +module_exit(falcon_gpio_exit);
1175 +++ b/arch/mips/include/asm/mach-lantiq/falcon/falcon.h
1178 + * This program is free software; you can redistribute it and/or modify
1179 + * it under the terms of the GNU General Public License as published by
1180 + * the Free Software Foundation; either version 2 of the License, or
1181 + * (at your option) any later version.
1183 + * Copyright (C) 2005 infineon
1184 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1187 +#ifdef CONFIG_SOC_LANTIQ_FALCON
1189 +#ifndef _LQ_FALCON_H__
1190 +#define _LQ_FALCON_H__
1192 +#include <lantiq.h>
1193 +#include <falcon/gpon_reg_base.h>
1195 +/*------------ GENERAL */
1196 +#define BOARD_SYSTEM_TYPE "LANTIQ"
1198 +/*------------ Chip IDs */
1199 +#define SOC_ID_FALCON 0x01B8
1201 +/*------------ SoC Types */
1202 +#define SOC_TYPE_FALCON 0x01
1208 +++ b/arch/mips/lantiq/falcon/reset.c
1211 + * This program is free software; you can redistribute it and/or modify
1212 + * it under the terms of the GNU General Public License as published by
1213 + * the Free Software Foundation; either version 2 of the License, or
1214 + * (at your option) any later version.
1216 + * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
1219 +#include <linux/init.h>
1220 +#include <linux/io.h>
1221 +#include <linux/pm.h>
1222 +#include <asm/reboot.h>
1224 +#include <falcon.h>
1225 +#include <falcon/gpon_reg_base.h>
1226 +#include <falcon/status_reg.h>
1227 +#include <falcon/sys1_reg.h>
1229 +static struct gpon_reg_sys1 * const pSYS1 = (struct gpon_reg_sys1 *)GPON_SYS1_BASE;
1231 +#define WDT_PW1 0x00BE0000
1232 +#define WDT_PW2 0x00DC0000
1233 +#define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
1236 +lq_machine_restart(char *command)
1238 + printk(KERN_NOTICE "System restart\n");
1239 + local_irq_disable();
1240 + lq_w32(0, (void*)0xBF200000); /* reset Bootreg RVEC */
1242 + lq_w32(RBT_CPU_TRIG, &pSYS1->rbt);
1244 + /* use workaround via watchdog timer */
1245 + lq_w32(WDT_PW1, (void*)WDT_REG_BASE);
1247 + (0x3 << 26) | /* PWL */
1248 + (0x2 << 24) | /* CLKDIV */
1249 + (0x1 << 31) | /* enable */
1251 + (void*)WDT_REG_BASE);
1257 +lq_machine_halt(void)
1259 + printk(KERN_NOTICE "System halted.\n");
1260 + local_irq_disable();
1265 +lq_machine_power_off(void)
1267 + printk(KERN_NOTICE "Please turn off the power now.\n");
1268 + local_irq_disable();
1273 +mips_reboot_setup(void)
1275 + _machine_restart = lq_machine_restart;
1276 + _machine_halt = lq_machine_halt;
1277 + pm_power_off = lq_machine_power_off;
1281 +arch_initcall(mips_reboot_setup);
1283 +++ b/arch/mips/lantiq/falcon/mach-easy98000.c
1285 +#include <linux/init.h>
1286 +#include <linux/platform_device.h>
1287 +#include <linux/leds.h>
1288 +#include <linux/gpio.h>
1289 +#include <linux/gpio_buttons.h>
1290 +#include <linux/etherdevice.h>
1291 +#include <linux/mtd/mtd.h>
1292 +#include <linux/mtd/partitions.h>
1293 +#include <linux/mtd/physmap.h>
1294 +#include <linux/input.h>
1295 +#include <linux/interrupt.h>
1296 +#include <linux/dm9000.h>
1297 +#include <linux/i2c.h>
1298 +#include <linux/i2c-gpio.h>
1299 +#include <linux/spi/spi.h>
1300 +#include <linux/spi/spi_gpio.h>
1301 +#include <linux/spi/eeprom.h>
1302 +#include <machine.h>
1304 +#include "devices.h"
1305 +#include "dev-leds-gpio.h"
1307 +#define EASY98000_GPIO_LED_0 9
1308 +#define EASY98000_GPIO_LED_1 10
1309 +#define EASY98000_GPIO_LED_2 11
1310 +#define EASY98000_GPIO_LED_3 12
1311 +#define EASY98000_GPIO_LED_4 13
1312 +#define EASY98000_GPIO_LED_5 14
1314 +extern unsigned char lq_ethaddr[6];
1316 +#ifdef CONFIG_MTD_PARTITIONS
1317 +static struct mtd_partition easy98000_nor_partitions[] =
1325 + .name = "uboot_env",
1326 + .offset = 0x40000,
1327 + .size = 0x40000, /* 2 sectors for redundant env. */
1331 + .offset = 0x80000,
1332 + .size = 0xF80000, /* map only 16 MiB */
1337 +static struct physmap_flash_data easy98000_nor_flash_data = {
1338 +#ifdef CONFIG_MTD_PARTITIONS
1339 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions),
1340 + .parts = easy98000_nor_partitions,
1344 +#ifdef CONFIG_MTD_PARTITIONS
1345 +static struct flash_platform_data easy98000_spi_flash_platform_data = {
1347 + .parts = easy98000_nor_partitions,
1348 + .nr_parts = ARRAY_SIZE(easy98000_nor_partitions)
1352 +static struct spi_board_info easy98000_spi_flash_data __initdata = {
1353 + .modalias = "m25p80",
1356 + .max_speed_hz = 10 * 1000 * 1000,
1357 + .mode = SPI_MODE_3,
1358 +#ifdef CONFIG_MTD_PARTITIONS
1359 + .platform_data = &easy98000_spi_flash_platform_data
1363 +static struct gpio_led easy98000_leds_gpio[] __initdata = {
1365 + .name = "easy98000:green:0",
1366 + .gpio = EASY98000_GPIO_LED_0,
1369 + .name = "easy98000:green:1",
1370 + .gpio = EASY98000_GPIO_LED_1,
1373 + .name = "easy98000:green:2",
1374 + .gpio = EASY98000_GPIO_LED_2,
1377 + .name = "easy98000:green:3",
1378 + .gpio = EASY98000_GPIO_LED_3,
1381 + .name = "easy98000:green:4",
1382 + .gpio = EASY98000_GPIO_LED_4,
1385 + .name = "easy98000:green:5",
1386 + .gpio = EASY98000_GPIO_LED_5,
1391 +#define CONFIG_DM9000_BASE 0x14000000
1392 +#define DM9000_IO (CONFIG_DM9000_BASE + 3)
1393 +#define DM9000_DATA (CONFIG_DM9000_BASE + 1)
1395 +static struct dm9000_plat_data dm9000_plat_data = {
1396 + .flags = DM9000_PLATF_8BITONLY,
1397 + //.dev_addr = { }, /* possibility to provide an ethernet address for the chip */
1400 +static struct resource dm9000_resources[] = {
1401 + MEM_RES("dm9000_io", DM9000_IO, DM9000_IO),
1402 + MEM_RES("dm9000_data", DM9000_DATA, DM9000_DATA),
1404 + /* with irq (210 -> gpio 110) the driver is very unreliable */
1405 + .start = -1, /* use polling */
1407 + .flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW,
1411 +static struct platform_device dm9000_platform = {
1414 + .num_resources = ARRAY_SIZE(dm9000_resources),
1415 + .resource = dm9000_resources,
1417 + .platform_data = (void *) &dm9000_plat_data,
1421 +static void __init register_davicom(void)
1423 + if (!is_valid_ether_addr(lq_ethaddr))
1424 + random_ether_addr(dm9000_plat_data.dev_addr);
1426 + memcpy(dm9000_plat_data.dev_addr, lq_ethaddr, 6);
1427 + /* change to "Locally Administered Address" */
1428 + dm9000_plat_data.dev_addr[0] |= 0x2;
1430 + platform_device_register(&dm9000_platform);
1433 +static struct i2c_gpio_platform_data easy98000_i2c_gpio_data = {
1438 +static struct platform_device easy98000_i2c_gpio_device = {
1439 + .name = "i2c-gpio",
1442 + .platform_data = &easy98000_i2c_gpio_data,
1446 +void __init register_easy98000_cpld_led(void)
1448 + platform_device_register_simple("easy98000_cpld_led", 0, NULL, 0);
1451 +/* setup gpio based spi bus/device for access to the eeprom on the board */
1452 +#define SPI_GPIO_MRST 102
1453 +#define SPI_GPIO_MTSR 103
1454 +#define SPI_GPIO_CLK 104
1455 +#define SPI_GPIO_CS0 105
1456 +#define SPI_GPIO_CS1 106
1457 +#define SPI_GPIO_BUS_NUM 1
1459 +static struct spi_gpio_platform_data easy98000_spi_gpio_data = {
1460 + .sck = SPI_GPIO_CLK,
1461 + .mosi = SPI_GPIO_MTSR,
1462 + .miso = SPI_GPIO_MRST,
1463 + .num_chipselect = 2,
1466 +static struct platform_device easy98000_spi_gpio_device = {
1467 + .name = "spi_gpio",
1468 + .id = SPI_GPIO_BUS_NUM,
1469 + .dev.platform_data = &easy98000_spi_gpio_data,
1472 +static struct spi_eeprom at25160n = {
1473 + .byte_len = 16 * 1024 / 8,
1474 + .name = "at25160n",
1476 + .flags = EE_ADDR2,
1479 +static struct spi_board_info easy98000_spi_gpio_devices __initdata = {
1480 + .modalias = "at25",
1481 + .bus_num = SPI_GPIO_BUS_NUM,
1482 + .max_speed_hz = 1000 * 1000,
1483 + .mode = SPI_MODE_3,
1485 + .controller_data = (void *) SPI_GPIO_CS1,
1486 + .platform_data = &at25160n,
1489 +static void __init easy98000_spi_gpio_init(void)
1491 + spi_register_board_info(&easy98000_spi_gpio_devices, 1);
1492 + platform_device_register(&easy98000_spi_gpio_device);
1495 +static void __init easy98000_init_common(void)
1497 + falcon_register_asc(0);
1498 + falcon_register_gpio();
1499 + falcon_register_wdt();
1500 + falcon_register_i2c();
1501 + platform_device_register(&easy98000_i2c_gpio_device);
1502 + register_davicom();
1503 + lq_add_device_leds_gpio(-1, ARRAY_SIZE(easy98000_leds_gpio),
1504 + easy98000_leds_gpio);
1505 + register_easy98000_cpld_led();
1506 + falcon_register_crypto();
1507 + easy98000_spi_gpio_init();
1510 +static void __init easy98000_init(void)
1512 + easy98000_init_common();
1513 + falcon_register_nor(&easy98000_nor_flash_data);
1516 +static void __init easy98000sf_init(void)
1518 + easy98000_init_common();
1519 + falcon_register_spi_flash(&easy98000_spi_flash_data);
1522 +MIPS_MACHINE(LANTIQ_MACH_EASY98000,
1524 + "EASY98000 Eval Board",
1527 +MIPS_MACHINE(LANTIQ_MACH_EASY98000SF,
1529 + "EASY98000 Eval Board (Serial Flash)",
1530 + easy98000sf_init);
1532 +++ b/arch/mips/lantiq/falcon/softdog_vpe.c
1535 +** =============================================================================
1536 +** FILE NAME : softdog_vpe.c
1538 +** DATE : 24-03-2008
1539 +** AUTHOR : LXDB Team
1540 +** DESCRIPTION : This header file contains the code for the watchdog
1541 +** implentation on vpe1 side.
1543 +** COPYRIGHT : Copyright (c) 2008
1544 +** Am Campeon 1-12, 85579 Neubiberg, Germany
1545 +** Any use of this software is subject to the conclusion of a respective
1546 +** License agreement. Without such a License agreement no rights to the
1547 +** software are granted
1550 +** $Date $Author $Comment
1551 +** 24-03-2008 LXDB Initial version
1552 +** ============================================================================
1555 +#include <linux/module.h>
1556 +#include <linux/moduleparam.h>
1557 +#include <linux/types.h>
1558 +#include <linux/timer.h>
1559 +#include <linux/reboot.h>
1560 +#include <linux/init.h>
1561 +#include <linux/jiffies.h>
1563 +#include <falcon/vpe.h>
1565 +static unsigned long last_wdog_value;
1566 +static unsigned long vpe1_wdog_cleared;
1568 +static unsigned long vpe1_wdog_dead;
1569 +static void watchdog_vpe0_fire(unsigned long); /* Called when vpe0 timer expires */
1570 +static void keep_alive_vpe0(unsigned long);
1571 +VPE_SW_WDOG_RESET reset_local_fn;
1574 +static struct timer_list watchdog_vpe0_ticktock =
1575 + TIMER_INITIALIZER(watchdog_vpe0_fire, 0, 0);
1577 +static void watchdog_vpe0_fire (unsigned long flags)
1579 + volatile unsigned long *wdog_ctr_value;
1580 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1581 + if (*wdog_ctr_value == last_wdog_value) { /* VPE1 watchdog expiry handling */
1582 + vpe1_sw_wdog_stop(flags);
1584 + printk(KERN_DEBUG "VPE1 watchdog reset handler called\n");
1585 + /* Call the reset handler function */
1586 + reset_local_fn(flags);
1587 + } else { /* Everything is OK on vpe1 side. Continue. */
1588 + last_wdog_value = *wdog_ctr_value;
1589 + vpe1_wdog_cleared++;
1590 + keep_alive_vpe0(flags);
1594 +int32_t vpe1_sw_wdog_register_reset_handler (VPE_SW_WDOG_RESET reset_fn)
1596 + reset_local_fn = (VPE_SW_WDOG_RESET)reset_fn;
1600 +static void keep_alive_vpe0(unsigned long flags)
1602 + mod_timer(&watchdog_vpe0_ticktock, jiffies+ vpe1_wdog_timeout );
1605 +unsigned long vpe1_sw_wdog_start(unsigned long flags)
1607 + volatile unsigned long *wdog_ctr_value;
1608 + wdog_ctr_value = (void*)vpe1_wdog_ctr;
1609 + *wdog_ctr_value = 0;
1610 + last_wdog_value = 0;
1611 + keep_alive_vpe0(flags);
1615 +unsigned long vpe1_sw_wdog_stop(unsigned long flags)
1617 + del_timer(&watchdog_vpe0_ticktock);
1621 +static int __init watchdog_vpe1_init(void)
1623 + /* Nothing to be done here */
1627 +static void __exit watchdog_vpe1_exit(void)
1629 + unsigned long flags=0;
1630 + vpe1_sw_wdog_stop(flags);
1633 +module_init(watchdog_vpe1_init);
1634 +module_exit(watchdog_vpe1_exit);
1636 +EXPORT_SYMBOL(vpe1_sw_wdog_register_reset_handler);
1637 +EXPORT_SYMBOL(vpe1_sw_wdog_start);
1638 +EXPORT_SYMBOL(vpe1_sw_wdog_stop);
1640 +MODULE_AUTHOR("LXDB");
1641 +MODULE_DESCRIPTION("Software Watchdog For VPE1");
1642 +MODULE_LICENSE("GPL");
1644 +++ b/arch/mips/include/asm/mach-lantiq/falcon/vpe.h
1647 + * This program is free software; you can redistribute it and/or modify
1648 + * it under the terms of the GNU General Public License as published by
1649 + * the Free Software Foundation; either version 2 of the License, or
1650 + * (at your option) any later version.
1652 + * This program is distributed in the hope that it will be useful,
1653 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1654 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1655 + * GNU General Public License for more details.
1657 + * You should have received a copy of the GNU General Public License
1658 + * along with this program; if not, write to the Free Software
1659 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
1661 + * Copyright (C) 2005 infineon
1662 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
1665 +#ifndef _IFXMIPS_VPE_H__
1666 +#define _IFXMIPS_VPE_H__
1668 +/* For the explanation of the APIs please refer the section "MT APRP Kernel
1669 + * Programming" in AR9 SW Architecture Specification
1671 +int32_t vpe1_sw_start(void* sw_start_addr, uint32_t tcmask, uint32_t flags);
1672 +int32_t vpe1_sw_stop(uint32_t flags);
1673 +uint32_t vpe1_get_load_addr (uint32_t flags);
1674 +uint32_t vpe1_get_max_mem (uint32_t flags);
1676 +int32_t vpe1_set_boot_param(char *field, char *value, char flags);
1677 +int32_t vpe1_get_boot_param(char *field, char **value, char flags);
1679 +/* Watchdog APIs */
1680 +extern unsigned long vpe1_wdog_ctr;
1681 +extern unsigned long vpe1_wdog_timeout;
1683 +unsigned long vpe1_sw_wdog_start(unsigned long);
1684 +unsigned long vpe1_sw_wdog_stop(unsigned long);
1686 +typedef int (*VPE_SW_WDOG_RESET)(unsigned long wdog_cleared_ok_count);
1687 +int32_t vpe1_sw_wdog_register_reset_handler(VPE_SW_WDOG_RESET reset_fn);
1690 --- a/arch/mips/lantiq/Kconfig
1691 +++ b/arch/mips/lantiq/Kconfig
1692 @@ -21,16 +21,16 @@ choice
1694 default SOC_LANTIQ_XWAY
1696 -#config SOC_LANTIQ_FALCON
1698 -# select SOC_LANTIQ
1699 +config SOC_LANTIQ_FALCON
1703 config SOC_LANTIQ_XWAY
1708 -#source "arch/mips/lantiq/falcon/Kconfig"
1709 +source "arch/mips/lantiq/falcon/Kconfig"
1710 source "arch/mips/lantiq/xway/Kconfig"
1713 --- a/arch/mips/include/asm/mach-lantiq/machine.h
1714 +++ b/arch/mips/include/asm/mach-lantiq/machine.h
1715 @@ -5,6 +5,7 @@ enum lantiq_mach_type {
1718 LANTIQ_MACH_EASY98000, /* Falcon Eval Board, NOR Flash */
1719 + LANTIQ_MACH_EASY98000SF, /* Falcon Eval Board, Serial Flash */
1720 LANTIQ_MACH_EASY98020, /* Falcon Reference Board */
1723 --- a/arch/mips/lantiq/Makefile
1724 +++ b/arch/mips/lantiq/Makefile
1726 obj-y := dev-leds-gpio.o irq.o setup.o clk.o prom.o
1727 obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
1728 +obj-$(CONFIG_SOC_LANTIQ_FALCON) += falcon/
1729 obj-$(CONFIG_SOC_LANTIQ_XWAY) += xway/
1730 --- a/arch/mips/lantiq/Platform
1731 +++ b/arch/mips/lantiq/Platform
1733 platform-$(CONFIG_LANTIQ) += lantiq/
1734 cflags-$(CONFIG_LANTIQ) += -I$(srctree)/arch/mips/include/asm/mach-lantiq
1735 load-$(CONFIG_LANTIQ) = 0xffffffff80002000
1736 +cflags-$(CONFIG_SOC_LANTIQ_FALCON) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/falcon
1737 cflags-$(CONFIG_SOC_LANTIQ_XWAY) += -I$(srctree)/arch/mips/include/asm/mach-lantiq/xway