···322322 This enables support for the MIPS Technologies Malta evaluation323323 board.324324325325+config MIPS_SEAD3326326+ bool "MIPS SEAD3 board"327327+ select BOOT_ELF32328328+ select BOOT_RAW329329+ select CEVT_R4K330330+ select CSRC_R4K331331+ select CPU_MIPSR2_IRQ_VI332332+ select CPU_MIPSR2_IRQ_EI333333+ select DMA_NONCOHERENT334334+ select IRQ_CPU335335+ select IRQ_GIC336336+ select MIPS_BOARDS_GEN337337+ select MIPS_CPU_SCACHE338338+ select MIPS_MSC339339+ select SYS_HAS_CPU_MIPS32_R1340340+ select SYS_HAS_CPU_MIPS32_R2341341+ select SYS_HAS_CPU_MIPS64_R1342342+ select SYS_HAS_EARLY_PRINTK343343+ select SYS_SUPPORTS_32BIT_KERNEL344344+ select SYS_SUPPORTS_64BIT_KERNEL345345+ select SYS_SUPPORTS_BIG_ENDIAN346346+ select SYS_SUPPORTS_LITTLE_ENDIAN347347+ select SYS_SUPPORTS_SMARTMIPS348348+ select USB_ARCH_HAS_EHCI349349+ select USB_EHCI_BIG_ENDIAN_DESC350350+ select USB_EHCI_BIG_ENDIAN_MMIO351351+ help352352+ This enables support for the MIPS Technologies SEAD3 evaluation353353+ board.354354+325355config NEC_MARKEINS326356 bool "NEC EMMA2RH Mark-eins board"327357 select SOC_EMMA2RH···17621732menu "Kernel type"1763173317641734choice17651765-17661735 prompt "Kernel code model"17671736 help17681737 You should only select this option if you have a workload that···1966193719671938config SYS_SUPPORTS_SCHED_SMT19681939 bool19691969-1970194019711941config SYS_SUPPORTS_MULTITHREADING19721942 bool
+124
arch/mips/configs/sead3_defconfig
···11+CONFIG_MIPS_SEAD3=y22+CONFIG_CPU_LITTLE_ENDIAN=y33+CONFIG_CPU_MIPS32_R2=y44+CONFIG_HZ_100=y55+CONFIG_EXPERIMENTAL=y66+CONFIG_SYSVIPC=y77+CONFIG_POSIX_MQUEUE=y88+CONFIG_NO_HZ=y99+CONFIG_HIGH_RES_TIMERS=y1010+CONFIG_IKCONFIG=y1111+CONFIG_IKCONFIG_PROC=y1212+CONFIG_LOG_BUF_SHIFT=151313+CONFIG_EMBEDDED=y1414+CONFIG_SLAB=y1515+CONFIG_PROFILING=y1616+CONFIG_OPROFILE=y1717+CONFIG_MODULES=y1818+# CONFIG_BLK_DEV_BSG is not set1919+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set2020+CONFIG_NET=y2121+CONFIG_PACKET=y2222+CONFIG_UNIX=y2323+CONFIG_INET=y2424+CONFIG_IP_PNP=y2525+CONFIG_IP_PNP_DHCP=y2626+CONFIG_IP_PNP_BOOTP=y2727+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set2828+# CONFIG_INET_XFRM_MODE_TUNNEL is not set2929+# CONFIG_INET_XFRM_MODE_BEET is not set3030+# CONFIG_INET_LRO is not set3131+# CONFIG_INET_DIAG is not set3232+# CONFIG_IPV6 is not set3333+# CONFIG_WIRELESS is not set3434+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"3535+CONFIG_MTD=y3636+CONFIG_MTD_CHAR=y3737+CONFIG_MTD_BLOCK=y3838+CONFIG_MTD_CFI=y3939+CONFIG_MTD_CFI_INTELEXT=y4040+CONFIG_MTD_PHYSMAP=y4141+CONFIG_MTD_UBI=y4242+CONFIG_MTD_UBI_GLUEBI=y4343+CONFIG_BLK_DEV_LOOP=y4444+CONFIG_BLK_DEV_CRYPTOLOOP=m4545+CONFIG_SCSI=y4646+# CONFIG_SCSI_PROC_FS is not set4747+CONFIG_BLK_DEV_SD=y4848+CONFIG_CHR_DEV_SG=y4949+# CONFIG_SCSI_LOWLEVEL is not set5050+CONFIG_NETDEVICES=y5151+CONFIG_SMSC911X=y5252+# CONFIG_NET_VENDOR_WIZNET is not set5353+CONFIG_MARVELL_PHY=y5454+CONFIG_DAVICOM_PHY=y5555+CONFIG_QSEMI_PHY=y5656+CONFIG_LXT_PHY=y5757+CONFIG_CICADA_PHY=y5858+CONFIG_VITESSE_PHY=y5959+CONFIG_SMSC_PHY=y6060+CONFIG_BROADCOM_PHY=y6161+CONFIG_ICPLUS_PHY=y6262+# CONFIG_WLAN is not set6363+# CONFIG_INPUT_MOUSEDEV is not set6464+# CONFIG_INPUT_KEYBOARD is not set6565+# CONFIG_INPUT_MOUSE is not set6666+# CONFIG_SERIO is not set6767+# CONFIG_CONSOLE_TRANSLATIONS is not set6868+CONFIG_VT_HW_CONSOLE_BINDING=y6969+CONFIG_LEGACY_PTY_COUNT=327070+CONFIG_SERIAL_8250=y7171+CONFIG_SERIAL_8250_CONSOLE=y7272+CONFIG_SERIAL_8250_NR_UARTS=27373+CONFIG_SERIAL_8250_RUNTIME_UARTS=27474+# CONFIG_HW_RANDOM is not set7575+CONFIG_I2C=y7676+# CONFIG_I2C_COMPAT is not set7777+CONFIG_I2C_CHARDEV=y7878+# CONFIG_I2C_HELPER_AUTO is not set7979+CONFIG_SPI=y8080+CONFIG_SENSORS_ADT7475=y8181+CONFIG_BACKLIGHT_LCD_SUPPORT=y8282+CONFIG_LCD_CLASS_DEVICE=y8383+CONFIG_BACKLIGHT_CLASS_DEVICE=y8484+# CONFIG_VGA_CONSOLE is not set8585+CONFIG_USB=y8686+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y8787+CONFIG_USB_EHCI_HCD=y8888+CONFIG_USB_EHCI_ROOT_HUB_TT=y8989+CONFIG_USB_STORAGE=y9090+CONFIG_MMC=y9191+CONFIG_MMC_DEBUG=y9292+CONFIG_MMC_SPI=y9393+CONFIG_NEW_LEDS=y9494+CONFIG_LEDS_CLASS=y9595+CONFIG_LEDS_TRIGGERS=y9696+CONFIG_LEDS_TRIGGER_HEARTBEAT=y9797+CONFIG_RTC_CLASS=y9898+CONFIG_RTC_DRV_M41T80=y9999+CONFIG_EXT3_FS=y100100+# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set101101+CONFIG_XFS_FS=y102102+CONFIG_XFS_QUOTA=y103103+CONFIG_XFS_POSIX_ACL=y104104+CONFIG_QUOTA=y105105+# CONFIG_PRINT_QUOTA_WARNING is not set106106+CONFIG_MSDOS_FS=m107107+CONFIG_VFAT_FS=m108108+CONFIG_TMPFS=y109109+CONFIG_JFFS2_FS=y110110+CONFIG_NFS_FS=y111111+CONFIG_ROOT_NFS=y112112+CONFIG_NLS_CODEPAGE_437=y113113+CONFIG_NLS_ASCII=y114114+CONFIG_NLS_ISO8859_1=y115115+CONFIG_NLS_ISO8859_15=y116116+CONFIG_NLS_UTF8=y117117+# CONFIG_FTRACE is not set118118+CONFIG_CRYPTO=y119119+CONFIG_CRYPTO_CBC=y120120+CONFIG_CRYPTO_ECB=y121121+CONFIG_CRYPTO_AES=y122122+CONFIG_CRYPTO_ARC4=y123123+# CONFIG_CRYPTO_ANSI_CPRNG is not set124124+# CONFIG_CRYPTO_HW is not set
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Chris Dearman (chris@mips.com)77+ * Copyright (C) 2007 Mips Technologies, Inc.88+ */99+#ifndef __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H1010+#define __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H1111+1212+ .macro kernel_entry_setup1313+#ifdef CONFIG_MIPS_MT_SMTC1414+ mfc0 t0, CP0_CONFIG1515+ bgez t0, 9f1616+ mfc0 t0, CP0_CONFIG, 11717+ bgez t0, 9f1818+ mfc0 t0, CP0_CONFIG, 21919+ bgez t0, 9f2020+ mfc0 t0, CP0_CONFIG, 32121+ and t0, 1<<22222+ bnez t0, 0f2323+9 :2424+ /* Assume we came from YAMON... */2525+ PTR_LA v0, 0x9fc00534 /* YAMON print */2626+ lw v0, (v0)2727+ move a0, zero2828+ PTR_LA a1, nonmt_processor2929+ jal v03030+3131+ PTR_LA v0, 0x9fc00520 /* YAMON exit */3232+ lw v0, (v0)3333+ li a0, 13434+ jal v03535+3636+1 : b 1b3737+3838+ __INITDATA3939+nonmt_processor :4040+ .asciz "SMTC kernel requires the MT ASE to run\n"4141+ __FINIT4242+0 :4343+#endif4444+ .endm4545+4646+/*4747+ * Do SMP slave processor setup necessary before we can safely execute C code.4848+ */4949+ .macro smp_slave_setup5050+ .endm5151+5252+#endif /* __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H */
+25
arch/mips/include/asm/mach-sead3/war.h
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>77+ */88+#ifndef __ASM_MIPS_MACH_MIPS_WAR_H99+#define __ASM_MIPS_MACH_MIPS_WAR_H1010+1111+#define R4600_V1_INDEX_ICACHEOP_WAR 01212+#define R4600_V1_HIT_CACHEOP_WAR 01313+#define R4600_V2_HIT_CACHEOP_WAR 01414+#define R5432_CP0_INTERRUPT_WAR 01515+#define BCM1250_M3_WAR 01616+#define SIBYTE_1956_WAR 01717+#define MIPS4K_ICACHE_REFILL_WAR 11818+#define MIPS_CACHE_SYNC_WAR 11919+#define TX49XX_ICACHE_INDEX_INV_WAR 02020+#define RM9000_CDEX_SMP_WAR 02121+#define ICACHE_REFILLS_WORKAROUND_WAR 12222+#define R10000_LLSC_WAR 02323+#define MIPS34K_MISSED_ITLB_WAR 02424+2525+#endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
+7-48
arch/mips/include/asm/mips-boards/maltaint.h
···11/*22- * Carsten Langgaard, carstenl@mips.com33- * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.45 *55- * ########################################################################66- *77- * This program is free software; you can distribute it and/or modify it88- * under the terms of the GNU General Public License (Version 2) as99- * published by the Free Software Foundation.1010- *1111- * This program is distributed in the hope it will be useful, but WITHOUT1212- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or1313- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License1414- * for more details.1515- *1616- * You should have received a copy of the GNU General Public License along1717- * with this program; if not, write to the Free Software Foundation, Inc.,1818- * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.1919- *2020- * ########################################################################2121- *2222- * Defines for the Malta interrupt controller.2323- *66+ * Copyright (C) 2000,2012 MIPS Technologies, Inc. All rights reserved.77+ * Carsten Langgaard <carstenl@mips.com>88+ * Steven J. Hill <sjhill@mips.com>249 */2510#ifndef _MIPS_MALTAINT_H2611#define _MIPS_MALTAINT_H27122828-#include <irq.h>1313+#define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8)29143015/*3116 * Interrupts 0..15 are used for Malta ISA compatible interrupts···6378#define MSC01E_INT_PERFCTR 106479#define MSC01E_INT_CPUCTR 1165806666-/* GIC's Nomenclature for Core Interrupt Pins on the Malta */6767-#define GIC_CPU_INT0 0 /* Core Interrupt 2 */6868-#define GIC_CPU_INT1 1 /* . */6969-#define GIC_CPU_INT2 2 /* . */7070-#define GIC_CPU_INT3 3 /* . */7171-#define GIC_CPU_INT4 4 /* . */7272-#define GIC_CPU_INT5 5 /* Core Interrupt 5 */7373-7474-/* MALTA GIC local interrupts */7575-#define GIC_INT_TMR (GIC_CPU_INT5)7676-#define GIC_INT_PERFCTR (GIC_CPU_INT5)7777-7878-/* GIC constants */7979-/* Add 2 to convert non-eic hw int # to eic vector # */8080-#define GIC_CPU_TO_VEC_OFFSET (2)8181-/* If we map an intr to pin X, GIC will actually generate vector X+1 */8282-#define GIC_PIN_TO_VEC_OFFSET (1)8383-8484-#define GIC_EXT_INTR(x) x8585-8681/* External Interrupts used for IPI */8782#define GIC_IPI_EXT_INTR_RESCHED_VPE0 168883#define GIC_IPI_EXT_INTR_CALLFNC_VPE0 17···72107#define GIC_IPI_EXT_INTR_CALLFNC_VPE2 2173108#define GIC_IPI_EXT_INTR_RESCHED_VPE3 2274109#define GIC_IPI_EXT_INTR_CALLFNC_VPE3 237575-7676-#define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 8)7777-7878-#ifndef __ASSEMBLY__7979-extern void maltaint_init(void);8080-#endif8111082111#endif /* !(_MIPS_MALTAINT_H) */
+19
arch/mips/include/asm/mips-boards/sead3int.h
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2000,2012 MIPS Technologies, Inc. All rights reserved.77+ * Douglas Leung <douglas@mips.com>88+ * Steven J. Hill <sjhill@mips.com>99+ */1010+#ifndef _MIPS_SEAD3INT_H1111+#define _MIPS_SEAD3INT_H1212+1313+/* SEAD-3 GIC address space definitions. */1414+#define GIC_BASE_ADDR 0x1b1c00001515+#define GIC_ADDRSPACE_SZ (128 * 1024)1616+1717+#define MIPS_GIC_IRQ_BASE (MIPS_CPU_IRQ_BASE + 0)1818+1919+#endif /* !(_MIPS_SEAD3INT_H) */
···11-#undef DEBUG22-11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2008 Ralf Baechle (ralf@linux-mips.org)77+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.88+ */39#include <linux/bitmap.h>410#include <linux/init.h>511#include <linux/smp.h>···137148#include <asm/io.h>159#include <asm/gic.h>1010+#include <asm/setup.h>1111+#include <asm/traps.h>1612#include <asm/gcmpregs.h>1713#include <linux/hardirq.h>1814#include <asm-generic/bitops/find.h>19151616+unsigned long _gic_base;1717+unsigned int gic_irq_base;1818+unsigned int gic_irq_flags[GIC_NUM_INTRS];20192121-static unsigned long _gic_base;2222-static unsigned int _irqbase;2323-static unsigned int gic_irq_flags[GIC_NUM_INTRS];2424-#define GIC_IRQ_FLAG_EDGE 0x00012020+/* The index into this array is the vector # of the interrupt. */2121+struct gic_shared_intr_map gic_shared_intr_map[GIC_NUM_INTRS];25222626-struct gic_pcpu_mask pcpu_masks[NR_CPUS];2323+static struct gic_pcpu_mask pcpu_masks[NR_CPUS];2724static struct gic_pending_regs pending_regs[NR_CPUS];2825static struct gic_intrmask_regs intrmask_regs[NR_CPUS];29262727+unsigned int gic_get_timer_pending(void)2828+{2929+ unsigned int vpe_pending;3030+3131+ GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), 0);3232+ GICREAD(GIC_REG(VPE_OTHER, GIC_VPE_PEND), vpe_pending);3333+ return (vpe_pending & GIC_VPE_PEND_TIMER_MSK);3434+}3535+3636+void gic_bind_eic_interrupt(int irq, int set)3737+{3838+ /* Convert irq vector # to hw int # */3939+ irq -= GIC_PIN_TO_VEC_OFFSET;4040+4141+ /* Set irq to use shadow set */4242+ GICWRITE(GIC_REG_ADDR(VPE_LOCAL, GIC_VPE_EIC_SS(irq)), set);4343+}4444+3045void gic_send_ipi(unsigned int intr)3146{3232- pr_debug("CPU%d: %s status %08x\n", smp_processor_id(), __func__,3333- read_c0_status());3447 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), 0x80000000 | intr);3548}36493737-/* This is Malta specific and needs to be exported */5050+static void gic_eic_irq_dispatch(void)5151+{5252+ unsigned int cause = read_c0_cause();5353+ int irq;5454+5555+ irq = (cause & ST0_IM) >> STATUSB_IP2;5656+ if (irq == 0)5757+ irq = -1;5858+5959+ if (irq >= 0)6060+ do_IRQ(gic_irq_base + irq);6161+ else6262+ spurious_interrupt();6363+}6464+3865static void __init vpe_local_setup(unsigned int numvpes)3966{4040- int i;4141- unsigned long timer_interrupt = 5, perf_interrupt = 5;6767+ unsigned long timer_intr = GIC_INT_TMR;6868+ unsigned long perf_intr = GIC_INT_PERFCTR;4269 unsigned int vpe_ctl;7070+ int i;7171+7272+ if (cpu_has_veic) {7373+ /*7474+ * GIC timer interrupt -> CPU HW Int X (vector X+2) ->7575+ * map to pin X+2-1 (since GIC adds 1)7676+ */7777+ timer_intr += (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET);7878+ /*7979+ * GIC perfcnt interrupt -> CPU HW Int X (vector X+2) ->8080+ * map to pin X+2-1 (since GIC adds 1)8181+ */8282+ perf_intr += (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET);8383+ }43844485 /*4586 * Setup the default performance counter timer interrupts···9946 GICREAD(GIC_REG(VPE_OTHER, GIC_VPE_CTL), vpe_ctl);10047 if (vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK)10148 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_TIMER_MAP),102102- GIC_MAP_TO_PIN_MSK | timer_interrupt);4949+ GIC_MAP_TO_PIN_MSK | timer_intr);5050+ if (cpu_has_veic) {5151+ set_vi_handler(timer_intr + GIC_PIN_TO_VEC_OFFSET,5252+ gic_eic_irq_dispatch);5353+ gic_shared_intr_map[timer_intr + GIC_PIN_TO_VEC_OFFSET].local_intr_mask |= GIC_VPE_RMASK_TIMER_MSK;5454+ }1035510456 if (vpe_ctl & GIC_VPE_CTL_PERFCNT_RTBL_MSK)10557 GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_PERFCTR_MAP),106106- GIC_MAP_TO_PIN_MSK | perf_interrupt);5858+ GIC_MAP_TO_PIN_MSK | perf_intr);5959+ if (cpu_has_veic) {6060+ set_vi_handler(perf_intr + GIC_PIN_TO_VEC_OFFSET, gic_eic_irq_dispatch);6161+ gic_shared_intr_map[perf_intr + GIC_PIN_TO_VEC_OFFSET].local_intr_mask |= GIC_VPE_RMASK_PERFCNT_MSK;6262+ }10763 }10864}10965···14280 bitmap_and(pending, pending, intrmask, GIC_NUM_INTRS);14381 bitmap_and(pending, pending, pcpu_mask, GIC_NUM_INTRS);14482145145- i = find_first_bit(pending, GIC_NUM_INTRS);146146-147147- pr_debug("CPU%d: %s pend=%d\n", smp_processor_id(), __func__, i);148148-149149- return i;150150-}151151-152152-static void gic_irq_ack(struct irq_data *d)153153-{154154- unsigned int irq = d->irq - _irqbase;155155-156156- pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);157157- GIC_CLR_INTR_MASK(irq);158158-159159- if (gic_irq_flags[irq] & GIC_IRQ_FLAG_EDGE)160160- GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq);8383+ return find_first_bit(pending, GIC_NUM_INTRS);16184}1628516386static void gic_mask_irq(struct irq_data *d)16487{165165- unsigned int irq = d->irq - _irqbase;166166- pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);167167- GIC_CLR_INTR_MASK(irq);8888+ GIC_CLR_INTR_MASK(d->irq - gic_irq_base);16889}1699017091static void gic_unmask_irq(struct irq_data *d)17192{172172- unsigned int irq = d->irq - _irqbase;173173- pr_debug("CPU%d: %s: irq%d\n", smp_processor_id(), __func__, irq);174174- GIC_SET_INTR_MASK(irq);9393+ GIC_SET_INTR_MASK(d->irq - gic_irq_base);17594}1769517796#ifdef CONFIG_SMP178178-17997static DEFINE_SPINLOCK(gic_lock);1809818199static int gic_set_affinity(struct irq_data *d, const struct cpumask *cpumask,182100 bool force)183101{184184- unsigned int irq = d->irq - _irqbase;102102+ unsigned int irq = (d->irq - gic_irq_base);185103 cpumask_t tmp = CPU_MASK_NONE;186104 unsigned long flags;187105 int i;188106189189- pr_debug("%s(%d) called\n", __func__, irq);190107 cpumask_and(&tmp, cpumask, cpu_online_mask);191108 if (cpus_empty(tmp))192109 return -1;···195154 .irq_mask = gic_mask_irq,196155 .irq_mask_ack = gic_mask_irq,197156 .irq_unmask = gic_unmask_irq,198198- .irq_eoi = gic_unmask_irq,157157+ .irq_eoi = gic_finish_irq,199158#ifdef CONFIG_SMP200159 .irq_set_affinity = gic_set_affinity,201160#endif···205164 unsigned int pin, unsigned int polarity, unsigned int trigtype,206165 unsigned int flags)207166{167167+ struct gic_shared_intr_map *map_ptr;168168+208169 /* Setup Intr to Pin mapping */209170 if (pin & GIC_MAP_TO_NMI_MSK) {210171 GICWRITE(GIC_REG_ADDR(SHARED, GIC_SH_MAP_TO_PIN(intr)), pin);···221178 GIC_MAP_TO_PIN_MSK | pin);222179 /* Setup Intr to CPU mapping */223180 GIC_SH_MAP_TO_VPE_SMASK(intr, cpu);181181+ if (cpu_has_veic) {182182+ set_vi_handler(pin + GIC_PIN_TO_VEC_OFFSET,183183+ gic_eic_irq_dispatch);184184+ map_ptr = &gic_shared_intr_map[pin + GIC_PIN_TO_VEC_OFFSET];185185+ if (map_ptr->num_shared_intr >= GIC_MAX_SHARED_INTR)186186+ BUG();187187+ map_ptr->intr_list[map_ptr->num_shared_intr++] = intr;188188+ }224189 }225190226191 /* Setup Intr Polarity */···242191 /* Initialise per-cpu Interrupt software masks */243192 if (flags & GIC_FLAG_IPI)244193 set_bit(intr, pcpu_masks[cpu].pcpu_mask);245245- if (flags & GIC_FLAG_TRANSPARENT)194194+ if ((flags & GIC_FLAG_TRANSPARENT) && (cpu_has_veic == 0))246195 GIC_SET_INTR_MASK(intr);247196 if (trigtype == GIC_TRIG_EDGE)248248- gic_irq_flags[intr] |= GIC_IRQ_FLAG_EDGE;197197+ gic_irq_flags[intr] |= GIC_TRIG_EDGE;249198}250199251200static void __init gic_basic_init(int numintrs, int numvpes,252201 struct gic_intr_map *intrmap, int mapsize)253202{254203 unsigned int i, cpu;204204+ unsigned int pin_offset = 0;205205+206206+ board_bind_eic_interrupt = &gic_bind_eic_interrupt;255207256208 /* Setup defaults */257209 for (i = 0; i < numintrs; i++) {258210 GIC_SET_POLARITY(i, GIC_POL_POS);259211 GIC_SET_TRIGGER(i, GIC_TRIG_LEVEL);260212 GIC_CLR_INTR_MASK(i);261261- if (i < GIC_NUM_INTRS)213213+ if (i < GIC_NUM_INTRS) {262214 gic_irq_flags[i] = 0;215215+ gic_shared_intr_map[i].num_shared_intr = 0;216216+ gic_shared_intr_map[i].local_intr_mask = 0;217217+ }263218 }219219+220220+ /*221221+ * In EIC mode, the HW_INT# is offset by (2-1). Need to subtract222222+ * one because the GIC will add one (since 0=no intr).223223+ */224224+ if (cpu_has_veic)225225+ pin_offset = (GIC_CPU_TO_VEC_OFFSET - GIC_PIN_TO_VEC_OFFSET);264226265227 /* Setup specifics */266228 for (i = 0; i < mapsize; i++) {···284220 continue;285221 gic_setup_intr(i,286222 intrmap[i].cpunum,287287- intrmap[i].pin,223223+ intrmap[i].pin + pin_offset,288224 intrmap[i].polarity,289225 intrmap[i].trigtype,290226 intrmap[i].flags);291227 }292228293229 vpe_local_setup(numvpes);294294-295295- for (i = _irqbase; i < (_irqbase + numintrs); i++)296296- irq_set_chip(i, &gic_irq_controller);297230}298231299232void __init gic_init(unsigned long gic_base_addr,···303242304243 _gic_base = (unsigned long) ioremap_nocache(gic_base_addr,305244 gic_addrspace_size);306306- _irqbase = irqbase;245245+ gic_irq_base = irqbase;307246308247 GICREAD(GIC_REG(SHARED, GIC_SH_CONFIG), gicconfig);309248 numintrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >>···312251313252 numvpes = (gicconfig & GIC_SH_CONFIG_NUMVPES_MSK) >>314253 GIC_SH_CONFIG_NUMVPES_SHF;315315-316316- pr_debug("%s called\n", __func__);254254+ numvpes = numvpes + 1;317255318256 gic_basic_init(numintrs, numvpes, intr_map, intr_map_size);257257+258258+ gic_platform_init(numintrs, &gic_irq_controller);319259}
+21
arch/mips/mm/c-r4k.c
···786786 }787787}788788789789+static inline void alias_74k_erratum(struct cpuinfo_mips *c)790790+{791791+ /*792792+ * Early versions of the 74K do not update the cache tags on a793793+ * vtag miss/ptag hit which can occur in the case of KSEG0/KUSEG794794+ * aliases. In this case it is better to treat the cache as always795795+ * having aliases.796796+ */797797+ if ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(2, 4, 0))798798+ c->dcache.flags |= MIPS_CACHE_VTAG;799799+ if ((c->processor_id & 0xff) == PRID_REV_ENCODE_332(2, 4, 0))800800+ write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND);801801+ if (((c->processor_id & 0xff00) == PRID_IMP_1074K) &&802802+ ((c->processor_id & 0xff) <= PRID_REV_ENCODE_332(1, 1, 0))) {803803+ c->dcache.flags |= MIPS_CACHE_VTAG;804804+ write_c0_config6(read_c0_config6() | MIPS_CONF6_SYND);805805+ }806806+}807807+789808static char *way_string[] __cpuinitdata = { NULL, "direct mapped", "2-way",790809 "3-way", "4-way", "5-way", "6-way", "7-way", "8-way"791810};···10751056 case CPU_34K:10761057 case CPU_74K:10771058 case CPU_1004K:10591059+ if (c->cputype == CPU_74K)10601060+ alias_74k_erratum(c);10781061 if ((read_c0_config7() & (1 << 16))) {10791062 /* effectively physically indexed dcache,10801063 thus no virtual aliases. */
+29-1
arch/mips/mm/tlbex.c
···449449 }450450451451 if (cpu_has_mips_r2) {452452- if (cpu_has_mips_r2_exec_hazard)452452+ /*453453+ * The architecture spec says an ehb is required here,454454+ * but a number of cores do not have the hazard and455455+ * using an ehb causes an expensive pipeline stall.456456+ */457457+ switch (current_cpu_type()) {458458+ case CPU_M14KC:459459+ case CPU_74K:460460+ break;461461+462462+ default:453463 uasm_i_ehb(p);464464+ break;465465+ }454466 tlbw(p);455467 return;456468 }···933921#endif934922 uasm_i_mfc0(p, tmp, C0_BADVADDR); /* get faulting address */935923 uasm_i_lw(p, ptr, uasm_rel_lo(pgdc), ptr);924924+925925+ if (cpu_has_mips_r2) {926926+ uasm_i_ext(p, tmp, tmp, PGDIR_SHIFT, (32 - PGDIR_SHIFT));927927+ uasm_i_ins(p, ptr, tmp, PGD_T_LOG2, (32 - PGDIR_SHIFT));928928+ return;929929+ }930930+936931 uasm_i_srl(p, tmp, tmp, PGDIR_SHIFT); /* get pgd only bits */937932 uasm_i_sll(p, tmp, tmp, PGD_T_LOG2);938933 uasm_i_addu(p, ptr, ptr, tmp); /* add in pgd offset */···975956976957static void __cpuinit build_get_ptep(u32 **p, unsigned int tmp, unsigned int ptr)977958{959959+ if (cpu_has_mips_r2) {960960+ /* PTE ptr offset is obtained from BadVAddr */961961+ UASM_i_MFC0(p, tmp, C0_BADVADDR);962962+ UASM_i_LW(p, ptr, 0, ptr);963963+ uasm_i_ext(p, tmp, tmp, PAGE_SHIFT+1, PGDIR_SHIFT-PAGE_SHIFT-1);964964+ uasm_i_ins(p, ptr, tmp, PTE_T_LOG2+1, PGDIR_SHIFT-PAGE_SHIFT-1);965965+ return;966966+ }967967+978968 /*979969 * Bug workaround for the Nevada. It seems as if under certain980970 * circumstances the move from cp0_context might produce a
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/kernel.h>99+#include <linux/module.h>1010+#include <linux/init.h>1111+#include <linux/platform_device.h>1212+#include <linux/leds.h>1313+#include <linux/err.h>1414+#include <linux/io.h>1515+1616+#define DRVNAME "sead3-led"1717+1818+static struct platform_device *pdev;1919+2020+static void sead3_pled_set(struct led_classdev *led_cdev,2121+ enum led_brightness value)2222+{2323+ pr_debug("sead3_pled_set\n");2424+ writel(value, (void __iomem *)0xBF000210); /* FIXME */2525+}2626+2727+static void sead3_fled_set(struct led_classdev *led_cdev,2828+ enum led_brightness value)2929+{3030+ pr_debug("sead3_fled_set\n");3131+ writel(value, (void __iomem *)0xBF000218); /* FIXME */3232+}3333+3434+static struct led_classdev sead3_pled = {3535+ .name = "sead3::pled",3636+ .brightness_set = sead3_pled_set,3737+};3838+3939+static struct led_classdev sead3_fled = {4040+ .name = "sead3::fled",4141+ .brightness_set = sead3_fled_set,4242+};4343+4444+#ifdef CONFIG_PM4545+static int sead3_led_suspend(struct platform_device *dev,4646+ pm_message_t state)4747+{4848+ led_classdev_suspend(&sead3_pled);4949+ led_classdev_suspend(&sead3_fled);5050+ return 0;5151+}5252+5353+static int sead3_led_resume(struct platform_device *dev)5454+{5555+ led_classdev_resume(&sead3_pled);5656+ led_classdev_resume(&sead3_fled);5757+ return 0;5858+}5959+#else6060+#define sead3_led_suspend NULL6161+#define sead3_led_resume NULL6262+#endif6363+6464+static int sead3_led_probe(struct platform_device *pdev)6565+{6666+ int ret;6767+6868+ ret = led_classdev_register(&pdev->dev, &sead3_pled);6969+ if (ret < 0)7070+ return ret;7171+7272+ ret = led_classdev_register(&pdev->dev, &sead3_fled);7373+ if (ret < 0)7474+ led_classdev_unregister(&sead3_pled);7575+7676+ return ret;7777+}7878+7979+static int sead3_led_remove(struct platform_device *pdev)8080+{8181+ led_classdev_unregister(&sead3_pled);8282+ led_classdev_unregister(&sead3_fled);8383+ return 0;8484+}8585+8686+static struct platform_driver sead3_led_driver = {8787+ .probe = sead3_led_probe,8888+ .remove = sead3_led_remove,8989+ .suspend = sead3_led_suspend,9090+ .resume = sead3_led_resume,9191+ .driver = {9292+ .name = DRVNAME,9393+ .owner = THIS_MODULE,9494+ },9595+};9696+9797+static int __init sead3_led_init(void)9898+{9999+ int ret;100100+101101+ ret = platform_driver_register(&sead3_led_driver);102102+ if (ret < 0)103103+ goto out;104104+105105+ pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);106106+ if (IS_ERR(pdev)) {107107+ ret = PTR_ERR(pdev);108108+ platform_driver_unregister(&sead3_led_driver);109109+ goto out;110110+ }111111+112112+out:113113+ return ret;114114+}115115+116116+static void __exit sead3_led_exit(void)117117+{118118+ platform_device_unregister(pdev);119119+ platform_driver_unregister(&sead3_led_driver);120120+}121121+122122+module_init(sead3_led_init);123123+module_exit(sead3_led_exit);124124+125125+MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");126126+MODULE_DESCRIPTION("SEAD3 LED driver");127127+MODULE_LICENSE("GPL");128128+
+46
arch/mips/mti-sead3/sead3-cmdline.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/string.h>1010+1111+#include <asm/bootinfo.h>1212+1313+extern int prom_argc;1414+extern int *_prom_argv;1515+1616+/*1717+ * YAMON (32-bit PROM) pass arguments and environment as 32-bit pointer.1818+ * This macro take care of sign extension.1919+ */2020+#define prom_argv(index) ((char *)(long)_prom_argv[(index)])2121+2222+char * __init prom_getcmdline(void)2323+{2424+ return &(arcs_cmdline[0]);2525+}2626+2727+void __init prom_init_cmdline(void)2828+{2929+ char *cp;3030+ int actr;3131+3232+ actr = 1; /* Always ignore argv[0] */3333+3434+ cp = &(arcs_cmdline[0]);3535+ while (actr < prom_argc) {3636+ strcpy(cp, prom_argv(actr));3737+ cp += strlen(prom_argv(actr));3838+ *cp++ = ' ';3939+ actr++;4040+ }4141+ if (cp != &(arcs_cmdline[0])) {4242+ /* get rid of trailing space */4343+ --cp;4444+ *cp = '\0';4545+ }4646+}
+46
arch/mips/mti-sead3/sead3-console.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/console.h>1010+#include <linux/serial_reg.h>1111+#include <linux/io.h>1212+1313+#define SEAD_UART1_REGS_BASE 0xbf000800 /* ttyS1 = DB9 port */1414+#define SEAD_UART0_REGS_BASE 0xbf000900 /* ttyS0 = USB port */1515+#define PORT(base_addr, offset) ((unsigned int __iomem *)(base_addr+(offset)*4))1616+1717+static char console_port = 1;1818+1919+static inline unsigned int serial_in(int offset, unsigned int base_addr)2020+{2121+ return __raw_readl(PORT(base_addr, offset)) & 0xff;2222+}2323+2424+static inline void serial_out(int offset, int value, unsigned int base_addr)2525+{2626+ __raw_writel(value, PORT(base_addr, offset));2727+}2828+2929+void __init prom_init_early_console(char port)3030+{3131+ console_port = port;3232+}3333+3434+int prom_putchar(char c)3535+{3636+ unsigned int base_addr;3737+3838+ base_addr = console_port ? SEAD_UART1_REGS_BASE : SEAD_UART0_REGS_BASE;3939+4040+ while ((serial_in(UART_LSR, base_addr) & UART_LSR_THRE) == 0)4141+ ;4242+4343+ serial_out(UART_TX, c, base_addr);4444+4545+ return 1;4646+}
+78
arch/mips/mti-sead3/sead3-display.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/timer.h>99+#include <linux/io.h>1010+#include <asm/mips-boards/generic.h>1111+#include <asm/mips-boards/prom.h>1212+1313+static unsigned int display_count;1414+static unsigned int max_display_count;1515+1616+#define LCD_DISPLAY_POS_BASE 0x1f0004001717+#define DISPLAY_LCDINSTRUCTION (0*2)1818+#define DISPLAY_LCDDATA (1*2)1919+#define DISPLAY_CPLDSTATUS (2*2)2020+#define DISPLAY_CPLDDATA (3*2)2121+#define LCD_SETDDRAM 0x802222+#define LCD_IR_BF 0x802323+2424+const char display_string[] = " LINUX ON SEAD3 ";2525+2626+static void scroll_display_message(unsigned long data);2727+static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0);2828+2929+static void lcd_wait(unsigned int __iomem *display)3030+{3131+ /* Wait for CPLD state machine to become idle. */3232+ do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);3333+3434+ do {3535+ __raw_readl(display + DISPLAY_LCDINSTRUCTION);3636+3737+ /* Wait for CPLD state machine to become idle. */3838+ do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);3939+ } while (__raw_readl(display + DISPLAY_CPLDDATA) & LCD_IR_BF);4040+}4141+4242+void mips_display_message(const char *str)4343+{4444+ static unsigned int __iomem *display;4545+ char ch;4646+ int i;4747+4848+ if (unlikely(display == NULL))4949+ display = ioremap_nocache(LCD_DISPLAY_POS_BASE,5050+ (8 * sizeof(int)));5151+5252+ for (i = 0; i < 16; i++) {5353+ if (*str)5454+ ch = *str++;5555+ else5656+ ch = ' ';5757+ lcd_wait(display);5858+ __raw_writel((LCD_SETDDRAM | i),5959+ (display + DISPLAY_LCDINSTRUCTION));6060+ lcd_wait(display);6161+ __raw_writel(ch, display + DISPLAY_LCDDATA);6262+ }6363+}6464+6565+static void scroll_display_message(unsigned long data)6666+{6767+ mips_display_message(&display_string[display_count++]);6868+ if (display_count == max_display_count)6969+ display_count = 0;7070+ mod_timer(&mips_scroll_timer, jiffies + HZ);7171+}7272+7373+void mips_scroll_message(void)7474+{7575+ del_timer_sync(&mips_scroll_timer);7676+ max_display_count = strlen(display_string) + 1 - 16;7777+ mod_timer(&mips_scroll_timer, jiffies + 1);7878+}
+47
arch/mips/mti-sead3/sead3-ehci.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/irq.h>1010+#include <linux/dma-mapping.h>1111+#include <linux/platform_device.h>1212+1313+struct resource ehci_resources[] = {1414+ {1515+ .start = 0x1b200000,1616+ .end = 0x1b200fff,1717+ .flags = IORESOURCE_MEM1818+ },1919+ {2020+ .start = MIPS_CPU_IRQ_BASE + 2,2121+ .flags = IORESOURCE_IRQ2222+ }2323+};2424+2525+u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32);2626+2727+static struct platform_device ehci_device = {2828+ .name = "sead3-ehci",2929+ .id = 0,3030+ .dev = {3131+ .dma_mask = &sead3_usbdev_dma_mask,3232+ .coherent_dma_mask = DMA_BIT_MASK(32)3333+ },3434+ .num_resources = ARRAY_SIZE(ehci_resources),3535+ .resource = ehci_resources3636+};3737+3838+static int __init ehci_init(void)3939+{4040+ return platform_device_register(&ehci_device);4141+}4242+4343+module_init(ehci_init);4444+4545+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");4646+MODULE_LICENSE("GPL");4747+MODULE_DESCRIPTION("EHCI probe driver for SEAD3");
+33
arch/mips/mti-sead3/sead3-i2c-dev.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/i2c.h>1010+1111+static struct i2c_board_info __initdata sead3_i2c_devices[] = {1212+ {1313+ I2C_BOARD_INFO("adt7476", 0x2c),1414+ .irq = 0,1515+ },1616+ {1717+ I2C_BOARD_INFO("m41t80", 0x68),1818+ .irq = 0,1919+ },2020+};2121+2222+static int __init sead3_i2c_init(void)2323+{2424+ int err;2525+2626+ err = i2c_register_board_info(0, sead3_i2c_devices,2727+ ARRAY_SIZE(sead3_i2c_devices));2828+ if (err < 0)2929+ pr_err("sead3-i2c-dev: cannot register board I2C devices\n");3030+ return err;3131+}3232+3333+arch_initcall(sead3_i2c_init);
+405
arch/mips/mti-sead3/sead3-i2c-drv.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/module.h>1010+#include <linux/slab.h>1111+#include <linux/delay.h>1212+#include <linux/i2c.h>1313+#include <linux/platform_device.h>1414+1515+#define PIC32_I2CxCON 0x00001616+#define PIC32_I2CCON_ON (1<<15)1717+#define PIC32_I2CCON_ACKDT (1<<5)1818+#define PIC32_I2CCON_ACKEN (1<<4)1919+#define PIC32_I2CCON_RCEN (1<<3)2020+#define PIC32_I2CCON_PEN (1<<2)2121+#define PIC32_I2CCON_RSEN (1<<1)2222+#define PIC32_I2CCON_SEN (1<<0)2323+#define PIC32_I2CxCONCLR 0x00042424+#define PIC32_I2CxCONSET 0x00082525+#define PIC32_I2CxSTAT 0x00102626+#define PIC32_I2CxSTATCLR 0x00142727+#define PIC32_I2CSTAT_ACKSTAT (1<<15)2828+#define PIC32_I2CSTAT_TRSTAT (1<<14)2929+#define PIC32_I2CSTAT_BCL (1<<10)3030+#define PIC32_I2CSTAT_IWCOL (1<<7)3131+#define PIC32_I2CSTAT_I2COV (1<<6)3232+#define PIC32_I2CxBRG 0x00403333+#define PIC32_I2CxTRN 0x00503434+#define PIC32_I2CxRCV 0x00603535+3636+static DEFINE_SPINLOCK(pic32_bus_lock);3737+3838+static void __iomem *bus_xfer = (void __iomem *)0xbf000600;3939+static void __iomem *bus_status = (void __iomem *)0xbf000060;4040+4141+#define DELAY() udelay(100)4242+4343+static inline unsigned int ioready(void)4444+{4545+ return readl(bus_status) & 1;4646+}4747+4848+static inline void wait_ioready(void)4949+{5050+ do { } while (!ioready());5151+}5252+5353+static inline void wait_ioclear(void)5454+{5555+ do { } while (ioready());5656+}5757+5858+static inline void check_ioclear(void)5959+{6060+ if (ioready()) {6161+ do {6262+ (void) readl(bus_xfer);6363+ DELAY();6464+ } while (ioready());6565+ }6666+}6767+6868+static u32 pic32_bus_readl(u32 reg)6969+{7070+ unsigned long flags;7171+ u32 status, val;7272+7373+ spin_lock_irqsave(&pic32_bus_lock, flags);7474+7575+ check_ioclear();7676+ writel((0x01 << 24) | (reg & 0x00ffffff), bus_xfer);7777+ DELAY();7878+ wait_ioready();7979+ status = readl(bus_xfer);8080+ DELAY();8181+ val = readl(bus_xfer);8282+ wait_ioclear();8383+8484+ spin_unlock_irqrestore(&pic32_bus_lock, flags);8585+8686+ return val;8787+}8888+8989+static void pic32_bus_writel(u32 val, u32 reg)9090+{9191+ unsigned long flags;9292+ u32 status;9393+9494+ spin_lock_irqsave(&pic32_bus_lock, flags);9595+9696+ check_ioclear();9797+ writel((0x10 << 24) | (reg & 0x00ffffff), bus_xfer);9898+ DELAY();9999+ writel(val, bus_xfer);100100+ DELAY();101101+ wait_ioready();102102+ status = readl(bus_xfer);103103+ wait_ioclear();104104+105105+ spin_unlock_irqrestore(&pic32_bus_lock, flags);106106+}107107+108108+struct pic32_i2c_platform_data {109109+ u32 base;110110+ struct i2c_adapter adap;111111+ u32 xfer_timeout;112112+ u32 ack_timeout;113113+ u32 ctl_timeout;114114+};115115+116116+static inline void pic32_i2c_start(struct pic32_i2c_platform_data *adap)117117+{118118+ pic32_bus_writel(PIC32_I2CCON_SEN, adap->base + PIC32_I2CxCONSET);119119+}120120+121121+static inline void pic32_i2c_stop(struct pic32_i2c_platform_data *adap)122122+{123123+ pic32_bus_writel(PIC32_I2CCON_PEN, adap->base + PIC32_I2CxCONSET);124124+}125125+126126+static inline void pic32_i2c_ack(struct pic32_i2c_platform_data *adap)127127+{128128+ pic32_bus_writel(PIC32_I2CCON_ACKDT, adap->base + PIC32_I2CxCONCLR);129129+ pic32_bus_writel(PIC32_I2CCON_ACKEN, adap->base + PIC32_I2CxCONSET);130130+}131131+132132+static inline void pic32_i2c_nack(struct pic32_i2c_platform_data *adap)133133+{134134+ pic32_bus_writel(PIC32_I2CCON_ACKDT, adap->base + PIC32_I2CxCONSET);135135+ pic32_bus_writel(PIC32_I2CCON_ACKEN, adap->base + PIC32_I2CxCONSET);136136+}137137+138138+static inline int pic32_i2c_idle(struct pic32_i2c_platform_data *adap)139139+{140140+ int i;141141+142142+ for (i = 0; i < adap->ctl_timeout; i++) {143143+ if (((pic32_bus_readl(adap->base + PIC32_I2CxCON) &144144+ (PIC32_I2CCON_ACKEN | PIC32_I2CCON_RCEN |145145+ PIC32_I2CCON_PEN | PIC32_I2CCON_RSEN |146146+ PIC32_I2CCON_SEN)) == 0) &&147147+ ((pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &148148+ (PIC32_I2CSTAT_TRSTAT)) == 0))149149+ return 0;150150+ udelay(1);151151+ }152152+ return -ETIMEDOUT;153153+}154154+155155+static inline u32 pic32_i2c_master_write(struct pic32_i2c_platform_data *adap,156156+ u32 byte)157157+{158158+ pic32_bus_writel(byte, adap->base + PIC32_I2CxTRN);159159+ return pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &160160+ PIC32_I2CSTAT_IWCOL;161161+}162162+163163+static inline u32 pic32_i2c_master_read(struct pic32_i2c_platform_data *adap)164164+{165165+ pic32_bus_writel(PIC32_I2CCON_RCEN, adap->base + PIC32_I2CxCONSET);166166+ while (pic32_bus_readl(adap->base + PIC32_I2CxCON) & PIC32_I2CCON_RCEN)167167+ ;168168+ pic32_bus_writel(PIC32_I2CSTAT_I2COV, adap->base + PIC32_I2CxSTATCLR);169169+ return pic32_bus_readl(adap->base + PIC32_I2CxRCV);170170+}171171+172172+static int pic32_i2c_address(struct pic32_i2c_platform_data *adap,173173+ unsigned int addr, int rd)174174+{175175+ pic32_i2c_idle(adap);176176+ pic32_i2c_start(adap);177177+ pic32_i2c_idle(adap);178178+179179+ addr <<= 1;180180+ if (rd)181181+ addr |= 1;182182+183183+ if (pic32_i2c_master_write(adap, addr))184184+ return -EIO;185185+ pic32_i2c_idle(adap);186186+ if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &187187+ PIC32_I2CSTAT_ACKSTAT)188188+ return -EIO;189189+ return 0;190190+}191191+192192+static int sead3_i2c_read(struct pic32_i2c_platform_data *adap,193193+ unsigned char *buf, unsigned int len)194194+{195195+ u32 data;196196+ int i;197197+198198+ i = 0;199199+ while (i < len) {200200+ data = pic32_i2c_master_read(adap);201201+ buf[i++] = data;202202+ if (i < len)203203+ pic32_i2c_ack(adap);204204+ else205205+ pic32_i2c_nack(adap);206206+ }207207+208208+ pic32_i2c_stop(adap);209209+ pic32_i2c_idle(adap);210210+ return 0;211211+}212212+213213+static int sead3_i2c_write(struct pic32_i2c_platform_data *adap,214214+ unsigned char *buf, unsigned int len)215215+{216216+ int i;217217+ u32 data;218218+219219+ i = 0;220220+ while (i < len) {221221+ data = buf[i];222222+ if (pic32_i2c_master_write(adap, data))223223+ return -EIO;224224+ pic32_i2c_idle(adap);225225+ if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &226226+ PIC32_I2CSTAT_ACKSTAT)227227+ return -EIO;228228+ i++;229229+ }230230+231231+ pic32_i2c_stop(adap);232232+ pic32_i2c_idle(adap);233233+ return 0;234234+}235235+236236+static int sead3_pic32_platform_xfer(struct i2c_adapter *i2c_adap,237237+ struct i2c_msg *msgs, int num)238238+{239239+ struct pic32_i2c_platform_data *adap = i2c_adap->algo_data;240240+ struct i2c_msg *p;241241+ int i, err = 0;242242+243243+ for (i = 0; i < num; i++) {244244+#define __BUFSIZE 80245245+ int ii;246246+ static char buf[__BUFSIZE];247247+ char *b = buf;248248+249249+ p = &msgs[i];250250+ b += sprintf(buf, " [%d bytes]", p->len);251251+ if ((p->flags & I2C_M_RD) == 0) {252252+ for (ii = 0; ii < p->len; ii++) {253253+ if (b < &buf[__BUFSIZE-4]) {254254+ b += sprintf(b, " %02x", p->buf[ii]);255255+ } else {256256+ strcat(b, "...");257257+ break;258258+ }259259+ }260260+ }261261+ }262262+263263+ for (i = 0; !err && i < num; i++) {264264+ p = &msgs[i];265265+ err = pic32_i2c_address(adap, p->addr, p->flags & I2C_M_RD);266266+ if (err || !p->len)267267+ continue;268268+ if (p->flags & I2C_M_RD)269269+ err = sead3_i2c_read(adap, p->buf, p->len);270270+ else271271+ err = sead3_i2c_write(adap, p->buf, p->len);272272+ }273273+274274+ /* Return the number of messages processed, or the error code. */275275+ if (err == 0)276276+ err = num;277277+278278+ return err;279279+}280280+281281+static u32 sead3_pic32_platform_func(struct i2c_adapter *adap)282282+{283283+ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;284284+}285285+286286+static const struct i2c_algorithm sead3_platform_algo = {287287+ .master_xfer = sead3_pic32_platform_xfer,288288+ .functionality = sead3_pic32_platform_func,289289+};290290+291291+static void sead3_i2c_platform_setup(struct pic32_i2c_platform_data *priv)292292+{293293+ pic32_bus_writel(500, priv->base + PIC32_I2CxBRG);294294+ pic32_bus_writel(PIC32_I2CCON_ON, priv->base + PIC32_I2CxCONCLR);295295+ pic32_bus_writel(PIC32_I2CCON_ON, priv->base + PIC32_I2CxCONSET);296296+ pic32_bus_writel(PIC32_I2CSTAT_BCL | PIC32_I2CSTAT_IWCOL,297297+ priv->base + PIC32_I2CxSTATCLR);298298+}299299+300300+static int __devinit sead3_i2c_platform_probe(struct platform_device *pdev)301301+{302302+ struct pic32_i2c_platform_data *priv;303303+ struct resource *r;304304+ int ret;305305+306306+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);307307+ if (!r) {308308+ ret = -ENODEV;309309+ goto out;310310+ }311311+312312+ priv = kzalloc(sizeof(struct pic32_i2c_platform_data), GFP_KERNEL);313313+ if (!priv) {314314+ ret = -ENOMEM;315315+ goto out;316316+ }317317+318318+ priv->base = r->start;319319+ if (!priv->base) {320320+ ret = -EBUSY;321321+ goto out_mem;322322+ }323323+324324+ priv->xfer_timeout = 200;325325+ priv->ack_timeout = 200;326326+ priv->ctl_timeout = 200;327327+328328+ priv->adap.nr = pdev->id;329329+ priv->adap.algo = &sead3_platform_algo;330330+ priv->adap.algo_data = priv;331331+ priv->adap.dev.parent = &pdev->dev;332332+ strlcpy(priv->adap.name, "SEAD3 PIC32", sizeof(priv->adap.name));333333+334334+ sead3_i2c_platform_setup(priv);335335+336336+ ret = i2c_add_numbered_adapter(&priv->adap);337337+ if (ret == 0) {338338+ platform_set_drvdata(pdev, priv);339339+ return 0;340340+ }341341+342342+out_mem:343343+ kfree(priv);344344+out:345345+ return ret;346346+}347347+348348+static int __devexit sead3_i2c_platform_remove(struct platform_device *pdev)349349+{350350+ struct pic32_i2c_platform_data *priv = platform_get_drvdata(pdev);351351+352352+ platform_set_drvdata(pdev, NULL);353353+ i2c_del_adapter(&priv->adap);354354+ kfree(priv);355355+ return 0;356356+}357357+358358+#ifdef CONFIG_PM359359+static int sead3_i2c_platform_suspend(struct platform_device *pdev,360360+ pm_message_t state)361361+{362362+ dev_dbg(&pdev->dev, "i2c_platform_disable\n");363363+ return 0;364364+}365365+366366+static int sead3_i2c_platform_resume(struct platform_device *pdev)367367+{368368+ struct pic32_i2c_platform_data *priv = platform_get_drvdata(pdev);369369+370370+ dev_dbg(&pdev->dev, "sead3_i2c_platform_setup\n");371371+ sead3_i2c_platform_setup(priv);372372+373373+ return 0;374374+}375375+#else376376+#define sead3_i2c_platform_suspend NULL377377+#define sead3_i2c_platform_resume NULL378378+#endif379379+380380+static struct platform_driver sead3_i2c_platform_driver = {381381+ .driver = {382382+ .name = "sead3-i2c",383383+ .owner = THIS_MODULE,384384+ },385385+ .probe = sead3_i2c_platform_probe,386386+ .remove = __devexit_p(sead3_i2c_platform_remove),387387+ .suspend = sead3_i2c_platform_suspend,388388+ .resume = sead3_i2c_platform_resume,389389+};390390+391391+static int __init sead3_i2c_platform_init(void)392392+{393393+ return platform_driver_register(&sead3_i2c_platform_driver);394394+}395395+module_init(sead3_i2c_platform_init);396396+397397+static void __exit sead3_i2c_platform_exit(void)398398+{399399+ platform_driver_unregister(&sead3_i2c_platform_driver);400400+}401401+module_exit(sead3_i2c_platform_exit);402402+403403+MODULE_AUTHOR("Chris Dearman, MIPS Technologies INC.");404404+MODULE_DESCRIPTION("SEAD3 PIC32 I2C driver");405405+MODULE_LICENSE("GPL");
+37
arch/mips/mti-sead3/sead3-i2c.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/init.h>1010+#include <linux/platform_device.h>1111+#include <irq.h>1212+1313+struct resource sead3_i2c_resources[] = {1414+ {1515+ .start = 0x805200,1616+ .end = 0x8053ff,1717+ .flags = IORESOURCE_MEM,1818+ },1919+};2020+2121+static struct platform_device sead3_i2c_device = {2222+ .name = "sead3-i2c",2323+ .id = 0,2424+ .num_resources = ARRAY_SIZE(sead3_i2c_resources),2525+ .resource = sead3_i2c_resources,2626+};2727+2828+static int __init sead3_i2c_init(void)2929+{3030+ return platform_device_register(&sead3_i2c_device);3131+}3232+3333+module_init(sead3_i2c_init);3434+3535+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");3636+MODULE_LICENSE("GPL");3737+MODULE_DESCRIPTION("I2C probe driver for SEAD3");
+91
arch/mips/mti-sead3/sead3-init.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/io.h>1010+1111+#include <asm/bootinfo.h>1212+#include <asm/cacheflush.h>1313+#include <asm/traps.h>1414+#include <asm/mips-boards/generic.h>1515+#include <asm/mips-boards/prom.h>1616+1717+extern void prom_init_early_console(char port);1818+1919+extern char except_vec_nmi;2020+extern char except_vec_ejtag_debug;2121+2222+int prom_argc;2323+int *_prom_argv, *_prom_envp;2424+2525+#define prom_envp(index) ((char *)(long)_prom_envp[(index)])2626+2727+char *prom_getenv(char *envname)2828+{2929+ /*3030+ * Return a pointer to the given environment variable.3131+ * In 64-bit mode: we're using 64-bit pointers, but all pointers3232+ * in the PROM structures are only 32-bit, so we need some3333+ * workarounds, if we are running in 64-bit mode.3434+ */3535+ int i, index = 0;3636+3737+ i = strlen(envname);3838+3939+ while (prom_envp(index)) {4040+ if (strncmp(envname, prom_envp(index), i) == 0)4141+ return prom_envp(index+1);4242+ index += 2;4343+ }4444+4545+ return NULL;4646+}4747+4848+static void __init mips_nmi_setup(void)4949+{5050+ void *base;5151+5252+ base = cpu_has_veic ?5353+ (void *)(CAC_BASE + 0xa80) :5454+ (void *)(CAC_BASE + 0x380);5555+ memcpy(base, &except_vec_nmi, 0x80);5656+ flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);5757+}5858+5959+static void __init mips_ejtag_setup(void)6060+{6161+ void *base;6262+6363+ base = cpu_has_veic ?6464+ (void *)(CAC_BASE + 0xa00) :6565+ (void *)(CAC_BASE + 0x300);6666+ memcpy(base, &except_vec_ejtag_debug, 0x80);6767+ flush_icache_range((unsigned long)base, (unsigned long)base + 0x80);6868+}6969+7070+void __init prom_init(void)7171+{7272+ prom_argc = fw_arg0;7373+ _prom_argv = (int *) fw_arg1;7474+ _prom_envp = (int *) fw_arg2;7575+7676+ board_nmi_handler_setup = mips_nmi_setup;7777+ board_ejtag_handler_setup = mips_ejtag_setup;7878+7979+ prom_init_cmdline();8080+ prom_meminit();8181+#ifdef CONFIG_EARLY_PRINTK8282+ if ((strstr(prom_getcmdline(), "console=ttyS0")) != NULL)8383+ prom_init_early_console(0);8484+ else if ((strstr(prom_getcmdline(), "console=ttyS1")) != NULL)8585+ prom_init_early_console(1);8686+#endif8787+#ifdef CONFIG_SERIAL_8250_CONSOLE8888+ if ((strstr(prom_getcmdline(), "console=")) == NULL)8989+ strcat(prom_getcmdline(), " console=ttyS0,38400n8r");9090+#endif9191+}
+158
arch/mips/mti-sead3/sead3-int.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/irq.h>1010+#include <linux/io.h>1111+1212+#include <asm/gic.h>1313+#include <asm/irq_cpu.h>1414+#include <asm/setup.h>1515+1616+#include <asm/mips-boards/sead3int.h>1717+1818+#define SEAD_CONFIG_GIC_PRESENT_SHF 11919+#define SEAD_CONFIG_GIC_PRESENT_MSK (1 << SEAD_CONFIG_GIC_PRESENT_SHF)2020+#define SEAD_CONFIG_BASE 0x1b1001102121+#define SEAD_CONFIG_SIZE 42222+2323+int gic_present;2424+static unsigned long sead3_config_reg;2525+2626+/*2727+ * This table defines the setup for each external GIC interrupt. It is2828+ * indexed by interrupt number.2929+ */3030+#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK3131+static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {3232+ { 0, GIC_CPU_INT4, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3333+ { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3434+ { 0, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3535+ { 0, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3636+ { 0, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3737+ { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3838+ { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },3939+ { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },4040+ { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },4141+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4242+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4343+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4444+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4545+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4646+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4747+ { GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED, GIC_UNUSED },4848+};4949+5050+asmlinkage void plat_irq_dispatch(void)5151+{5252+ unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;5353+ int irq;5454+5555+ irq = (fls(pending) - CAUSEB_IP - 1);5656+ if (irq >= 0)5757+ do_IRQ(MIPS_CPU_IRQ_BASE + irq);5858+ else5959+ spurious_interrupt();6060+}6161+6262+void __init arch_init_irq(void)6363+{6464+ int i;6565+6666+ if (!cpu_has_veic) {6767+ mips_cpu_irq_init();6868+6969+ if (cpu_has_vint) {7070+ /* install generic handler */7171+ for (i = 0; i < 8; i++)7272+ set_vi_handler(i, plat_irq_dispatch);7373+ }7474+ }7575+7676+ sead3_config_reg = (unsigned long)ioremap_nocache(SEAD_CONFIG_BASE,7777+ SEAD_CONFIG_SIZE);7878+ gic_present = (REG32(sead3_config_reg) & SEAD_CONFIG_GIC_PRESENT_MSK) >>7979+ SEAD_CONFIG_GIC_PRESENT_SHF;8080+ pr_info("GIC: %spresent\n", (gic_present) ? "" : "not ");8181+ pr_info("EIC: %s\n",8282+ (current_cpu_data.options & MIPS_CPU_VEIC) ? "on" : "off");8383+8484+ if (gic_present)8585+ gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map,8686+ ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);8787+}8888+8989+void gic_enable_interrupt(int irq_vec)9090+{9191+ unsigned int i, irq_source;9292+9393+ /* enable all the interrupts associated with this vector */9494+ for (i = 0; i < gic_shared_intr_map[irq_vec].num_shared_intr; i++) {9595+ irq_source = gic_shared_intr_map[irq_vec].intr_list[i];9696+ GIC_SET_INTR_MASK(irq_source);9797+ }9898+ /* enable all local interrupts associated with this vector */9999+ if (gic_shared_intr_map[irq_vec].local_intr_mask) {100100+ GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), 0);101101+ GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_SMASK),102102+ gic_shared_intr_map[irq_vec].local_intr_mask);103103+ }104104+}105105+106106+void gic_disable_interrupt(int irq_vec)107107+{108108+ unsigned int i, irq_source;109109+110110+ /* disable all the interrupts associated with this vector */111111+ for (i = 0; i < gic_shared_intr_map[irq_vec].num_shared_intr; i++) {112112+ irq_source = gic_shared_intr_map[irq_vec].intr_list[i];113113+ GIC_CLR_INTR_MASK(irq_source);114114+ }115115+ /* disable all local interrupts associated with this vector */116116+ if (gic_shared_intr_map[irq_vec].local_intr_mask) {117117+ GICWRITE(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), 0);118118+ GICWRITE(GIC_REG(VPE_OTHER, GIC_VPE_RMASK),119119+ gic_shared_intr_map[irq_vec].local_intr_mask);120120+ }121121+}122122+123123+void gic_irq_ack(struct irq_data *d)124124+{125125+ GIC_CLR_INTR_MASK(d->irq - gic_irq_base);126126+}127127+128128+void gic_finish_irq(struct irq_data *d)129129+{130130+ unsigned int irq = (d->irq - gic_irq_base);131131+ unsigned int i, irq_source;132132+133133+ /* Clear edge detectors. */134134+ for (i = 0; i < gic_shared_intr_map[irq].num_shared_intr; i++) {135135+ irq_source = gic_shared_intr_map[irq].intr_list[i];136136+ if (gic_irq_flags[irq_source] & GIC_TRIG_EDGE)137137+ GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq_source);138138+ }139139+140140+ /* Enable interrupts. */141141+ GIC_SET_INTR_MASK(irq);142142+}143143+144144+void __init gic_platform_init(int irqs, struct irq_chip *irq_controller)145145+{146146+ int i;147147+148148+ /*149149+ * For non-EIC mode, we want to setup the GIC in pass-through150150+ * mode, as if the GIC didn't exist. Do not map any interrupts151151+ * for an external interrupt controller.152152+ */153153+ if (!cpu_has_veic)154154+ return;155155+156156+ for (i = gic_irq_base; i < (gic_irq_base + irqs); i++)157157+ irq_set_chip_and_handler(i, irq_controller, handle_percpu_irq);158158+}
+43
arch/mips/mti-sead3/sead3-lcd.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/platform_device.h>1010+1111+static struct resource __initdata sead3_lcd_resource = {1212+ .start = 0x1f000400,1313+ .end = 0x1f00041f,1414+ .flags = IORESOURCE_MEM,1515+};1616+1717+static __init int sead3_lcd_add(void)1818+{1919+ struct platform_device *pdev;2020+ int retval;2121+2222+ /* SEAD-3 and Cobalt platforms use same display type. */2323+ pdev = platform_device_alloc("cobalt-lcd", -1);2424+ if (!pdev)2525+ return -ENOMEM;2626+2727+ retval = platform_device_add_resources(pdev, &sead3_lcd_resource, 1);2828+ if (retval)2929+ goto err_free_device;3030+3131+ retval = platform_device_add(pdev);3232+ if (retval)3333+ goto err_free_device;3434+3535+ return 0;3636+3737+err_free_device:3838+ platform_device_put(pdev);3939+4040+ return retval;4141+}4242+4343+device_initcall(sead3_lcd_add);
+83
arch/mips/mti-sead3/sead3-leds.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/leds.h>1010+#include <linux/platform_device.h>1111+1212+#define LEDFLAGS(bits, shift) \1313+ ((bits << 8) | (shift << 8))1414+1515+#define LEDBITS(id, shift, bits) \1616+ .name = id #shift, \1717+ .flags = LEDFLAGS(bits, shift)1818+1919+struct led_info led_data_info[] = {2020+ { LEDBITS("bit", 0, 1) },2121+ { LEDBITS("bit", 1, 1) },2222+ { LEDBITS("bit", 2, 1) },2323+ { LEDBITS("bit", 3, 1) },2424+ { LEDBITS("bit", 4, 1) },2525+ { LEDBITS("bit", 5, 1) },2626+ { LEDBITS("bit", 6, 1) },2727+ { LEDBITS("bit", 7, 1) },2828+ { LEDBITS("all", 0, 8) },2929+};3030+3131+static struct led_platform_data led_data = {3232+ .num_leds = ARRAY_SIZE(led_data_info),3333+ .leds = led_data_info3434+};3535+3636+static struct resource pled_resources[] = {3737+ {3838+ .start = 0x1f000210,3939+ .end = 0x1f000217,4040+ .flags = IORESOURCE_MEM4141+ }4242+};4343+4444+static struct platform_device pled_device = {4545+ .name = "sead3::pled",4646+ .id = 0,4747+ .dev = {4848+ .platform_data = &led_data,4949+ },5050+ .num_resources = ARRAY_SIZE(pled_resources),5151+ .resource = pled_resources5252+};5353+5454+5555+static struct resource fled_resources[] = {5656+ {5757+ .start = 0x1f000218,5858+ .end = 0x1f00021f,5959+ .flags = IORESOURCE_MEM6060+ }6161+};6262+6363+static struct platform_device fled_device = {6464+ .name = "sead3::fled",6565+ .id = 0,6666+ .dev = {6767+ .platform_data = &led_data,6868+ },6969+ .num_resources = ARRAY_SIZE(fled_resources),7070+ .resource = fled_resources7171+};7272+7373+static int __init led_init(void)7474+{7575+ platform_device_register(&pled_device);7676+ return platform_device_register(&fled_device);7777+}7878+7979+module_init(led_init);8080+8181+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");8282+MODULE_LICENSE("GPL");8383+MODULE_DESCRIPTION("LED probe driver for SEAD-3");
+138
arch/mips/mti-sead3/sead3-memory.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/bootmem.h>99+1010+#include <asm/bootinfo.h>1111+#include <asm/sections.h>1212+#include <asm/mips-boards/prom.h>1313+1414+enum yamon_memtypes {1515+ yamon_dontuse,1616+ yamon_prom,1717+ yamon_free,1818+};1919+2020+static struct prom_pmemblock mdesc[PROM_MAX_PMEMBLOCKS];2121+2222+/* determined physical memory size, not overridden by command line args */2323+unsigned long physical_memsize = 0L;2424+2525+struct prom_pmemblock * __init prom_getmdesc(void)2626+{2727+ char *memsize_str, *ptr;2828+ unsigned int memsize;2929+ static char cmdline[COMMAND_LINE_SIZE] __initdata;3030+ long val;3131+ int tmp;3232+3333+ /* otherwise look in the environment */3434+ memsize_str = prom_getenv("memsize");3535+ if (!memsize_str) {3636+ pr_warn("memsize not set in boot prom, set to default 32Mb\n");3737+ physical_memsize = 0x02000000;3838+ } else {3939+ tmp = kstrtol(memsize_str, 0, &val);4040+ physical_memsize = (unsigned long)val;4141+ }4242+4343+#ifdef CONFIG_CPU_BIG_ENDIAN4444+ /* SOC-it swaps, or perhaps doesn't swap, when DMA'ing the last4545+ word of physical memory */4646+ physical_memsize -= PAGE_SIZE;4747+#endif4848+4949+ /* Check the command line for a memsize directive that overrides5050+ the physical/default amount */5151+ strcpy(cmdline, arcs_cmdline);5252+ ptr = strstr(cmdline, "memsize=");5353+ if (ptr && (ptr != cmdline) && (*(ptr - 1) != ' '))5454+ ptr = strstr(ptr, " memsize=");5555+5656+ if (ptr)5757+ memsize = memparse(ptr + 8, &ptr);5858+ else5959+ memsize = physical_memsize;6060+6161+ memset(mdesc, 0, sizeof(mdesc));6262+6363+ mdesc[0].type = yamon_dontuse;6464+ mdesc[0].base = 0x00000000;6565+ mdesc[0].size = 0x00001000;6666+6767+ mdesc[1].type = yamon_prom;6868+ mdesc[1].base = 0x00001000;6969+ mdesc[1].size = 0x000ef000;7070+7171+ /*7272+ * The area 0x000f0000-0x000fffff is allocated for BIOS memory by the7373+ * south bridge and PCI access always forwarded to the ISA Bus and7474+ * BIOSCS# is always generated.7575+ * This mean that this area can't be used as DMA memory for PCI7676+ * devices.7777+ */7878+ mdesc[2].type = yamon_dontuse;7979+ mdesc[2].base = 0x000f0000;8080+ mdesc[2].size = 0x00010000;8181+8282+ mdesc[3].type = yamon_dontuse;8383+ mdesc[3].base = 0x00100000;8484+ mdesc[3].size = CPHYSADDR(PFN_ALIGN((unsigned long)&_end)) -8585+ mdesc[3].base;8686+8787+ mdesc[4].type = yamon_free;8888+ mdesc[4].base = CPHYSADDR(PFN_ALIGN(&_end));8989+ mdesc[4].size = memsize - mdesc[4].base;9090+9191+ return &mdesc[0];9292+}9393+9494+static int __init prom_memtype_classify(unsigned int type)9595+{9696+ switch (type) {9797+ case yamon_free:9898+ return BOOT_MEM_RAM;9999+ case yamon_prom:100100+ return BOOT_MEM_ROM_DATA;101101+ default:102102+ return BOOT_MEM_RESERVED;103103+ }104104+}105105+106106+void __init prom_meminit(void)107107+{108108+ struct prom_pmemblock *p;109109+110110+ p = prom_getmdesc();111111+112112+ while (p->size) {113113+ long type;114114+ unsigned long base, size;115115+116116+ type = prom_memtype_classify(p->type);117117+ base = p->base;118118+ size = p->size;119119+120120+ add_memory_region(base, size, type);121121+ p++;122122+ }123123+}124124+125125+void __init prom_free_prom_memory(void)126126+{127127+ unsigned long addr;128128+ int i;129129+130130+ for (i = 0; i < boot_mem_map.nr_map; i++) {131131+ if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)132132+ continue;133133+134134+ addr = boot_mem_map.map[i].addr;135135+ free_init_pages("prom memory",136136+ addr, addr + boot_mem_map.map[i].size);137137+ }138138+}
+54
arch/mips/mti-sead3/sead3-mtd.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+#include <linux/platform_device.h>1010+#include <linux/mtd/physmap.h>1111+1212+static struct mtd_partition sead3_mtd_partitions[] = {1313+ {1414+ .name = "User FS",1515+ .offset = 0x00000000,1616+ .size = 0x01fc0000,1717+ }, {1818+ .name = "Board Config",1919+ .offset = 0x01fc0000,2020+ .size = 0x00040000,2121+ .mask_flags = MTD_WRITEABLE2222+ },2323+};2424+2525+static struct physmap_flash_data sead3_flash_data = {2626+ .width = 4,2727+ .nr_parts = ARRAY_SIZE(sead3_mtd_partitions),2828+ .parts = sead3_mtd_partitions2929+};3030+3131+static struct resource sead3_flash_resource = {3232+ .start = 0x1c000000,3333+ .end = 0x1dffffff,3434+ .flags = IORESOURCE_MEM3535+};3636+3737+static struct platform_device sead3_flash = {3838+ .name = "physmap-flash",3939+ .id = 0,4040+ .dev = {4141+ .platform_data = &sead3_flash_data,4242+ },4343+ .num_resources = 1,4444+ .resource = &sead3_flash_resource,4545+};4646+4747+static int __init sead3_mtd_init(void)4848+{4949+ platform_device_register(&sead3_flash);5050+5151+ return 0;5252+}5353+5454+module_init(sead3_mtd_init)
+51
arch/mips/mti-sead3/sead3-net.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/irq.h>1010+#include <linux/platform_device.h>1111+#include <linux/smsc911x.h>1212+1313+static struct smsc911x_platform_config sead3_smsc911x_data = {1414+ .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,1515+ .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,1616+ .flags = SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,1717+ .phy_interface = PHY_INTERFACE_MODE_MII,1818+};1919+2020+struct resource sead3_net_resourcess[] = {2121+ {2222+ .start = 0x1f010000,2323+ .end = 0x1f01ffff,2424+ .flags = IORESOURCE_MEM2525+ },2626+ {2727+ .start = MIPS_CPU_IRQ_BASE + 6,2828+ .flags = IORESOURCE_IRQ2929+ }3030+};3131+3232+static struct platform_device sead3_net_device = {3333+ .name = "smsc911x",3434+ .id = 0,3535+ .dev = {3636+ .platform_data = &sead3_smsc911x_data,3737+ },3838+ .num_resources = ARRAY_SIZE(sead3_net_resourcess),3939+ .resource = sead3_net_resourcess4040+};4141+4242+static int __init sead3_net_init(void)4343+{4444+ return platform_device_register(&sead3_net_device);4545+}4646+4747+module_init(sead3_net_init);4848+4949+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");5050+MODULE_LICENSE("GPL");5151+MODULE_DESCRIPTION("Network probe driver for SEAD-3");
+103
arch/mips/mti-sead3/sead3-pic32-bus.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/delay.h>99+#include <linux/kernel.h>1010+#include <linux/spinlock.h>1111+#include <linux/init.h>1212+#include <linux/io.h>1313+#include <linux/errno.h>1414+1515+#define PIC32_NULL 0x001616+#define PIC32_RD 0x011717+#define PIC32_SYSRD 0x021818+#define PIC32_WR 0x101919+#define PIC32_SYSWR 0x202020+#define PIC32_IRQ_CLR 0x402121+#define PIC32_STATUS 0x802222+2323+#define DELAY() udelay(100) /* FIXME: needed? */2424+2525+/* spinlock to ensure atomic access to PIC32 */2626+static DEFINE_SPINLOCK(pic32_bus_lock);2727+2828+/* FIXME: io_remap these */2929+static void __iomem *bus_xfer = (void __iomem *)0xbf000600;3030+static void __iomem *bus_status = (void __iomem *)0xbf000060;3131+3232+static inline unsigned int ioready(void)3333+{3434+ return readl(bus_status) & 1;3535+}3636+3737+static inline void wait_ioready(void)3838+{3939+ do { } while (!ioready());4040+}4141+4242+static inline void wait_ioclear(void)4343+{4444+ do { } while (ioready());4545+}4646+4747+static inline void check_ioclear(void)4848+{4949+ if (ioready()) {5050+ pr_debug("ioclear: initially busy\n");5151+ do {5252+ (void) readl(bus_xfer);5353+ DELAY();5454+ } while (ioready());5555+ pr_debug("ioclear: cleared busy\n");5656+ }5757+}5858+5959+u32 pic32_bus_readl(u32 reg)6060+{6161+ unsigned long flags;6262+ u32 status, val;6363+6464+ spin_lock_irqsave(&pic32_bus_lock, flags);6565+6666+ check_ioclear();6767+6868+ writel((PIC32_RD << 24) | (reg & 0x00ffffff), bus_xfer);6969+ DELAY();7070+ wait_ioready();7171+ status = readl(bus_xfer);7272+ DELAY();7373+ val = readl(bus_xfer);7474+ wait_ioclear();7575+7676+ pr_debug("pic32_bus_readl: *%x -> %x (status=%x)\n", reg, val, status);7777+7878+ spin_unlock_irqrestore(&pic32_bus_lock, flags);7979+8080+ return val;8181+}8282+8383+void pic32_bus_writel(u32 val, u32 reg)8484+{8585+ unsigned long flags;8686+ u32 status;8787+8888+ spin_lock_irqsave(&pic32_bus_lock, flags);8989+9090+ check_ioclear();9191+9292+ writel((PIC32_WR << 24) | (reg & 0x00ffffff), bus_xfer);9393+ DELAY();9494+ writel(val, bus_xfer);9595+ DELAY();9696+ wait_ioready();9797+ status = readl(bus_xfer);9898+ wait_ioclear();9999+100100+ pr_debug("pic32_bus_writel: *%x <- %x (status=%x)\n", reg, val, status);101101+102102+ spin_unlock_irqrestore(&pic32_bus_lock, flags);103103+}
+435
arch/mips/mti-sead3/sead3-pic32-i2c-drv.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/delay.h>99+#include <linux/kernel.h>1010+#include <linux/module.h>1111+#include <linux/spinlock.h>1212+#include <linux/platform_device.h>1313+#include <linux/init.h>1414+#include <linux/errno.h>1515+#include <linux/i2c.h>1616+#include <linux/slab.h>1717+1818+#define PIC32_I2CxCON 0x00001919+#define PIC32_I2CxCONCLR 0x00042020+#define PIC32_I2CxCONSET 0x00082121+#define PIC32_I2CxCONINV 0x000C2222+#define I2CCON_ON (1<<15)2323+#define I2CCON_FRZ (1<<14)2424+#define I2CCON_SIDL (1<<13)2525+#define I2CCON_SCLREL (1<<12)2626+#define I2CCON_STRICT (1<<11)2727+#define I2CCON_A10M (1<<10)2828+#define I2CCON_DISSLW (1<<9)2929+#define I2CCON_SMEN (1<<8)3030+#define I2CCON_GCEN (1<<7)3131+#define I2CCON_STREN (1<<6)3232+#define I2CCON_ACKDT (1<<5)3333+#define I2CCON_ACKEN (1<<4)3434+#define I2CCON_RCEN (1<<3)3535+#define I2CCON_PEN (1<<2)3636+#define I2CCON_RSEN (1<<1)3737+#define I2CCON_SEN (1<<0)3838+3939+#define PIC32_I2CxSTAT 0x00104040+#define PIC32_I2CxSTATCLR 0x00144141+#define PIC32_I2CxSTATSET 0x00184242+#define PIC32_I2CxSTATINV 0x001C4343+#define I2CSTAT_ACKSTAT (1<<15)4444+#define I2CSTAT_TRSTAT (1<<14)4545+#define I2CSTAT_BCL (1<<10)4646+#define I2CSTAT_GCSTAT (1<<9)4747+#define I2CSTAT_ADD10 (1<<8)4848+#define I2CSTAT_IWCOL (1<<7)4949+#define I2CSTAT_I2COV (1<<6)5050+#define I2CSTAT_DA (1<<5)5151+#define I2CSTAT_P (1<<4)5252+#define I2CSTAT_S (1<<3)5353+#define I2CSTAT_RW (1<<2)5454+#define I2CSTAT_RBF (1<<1)5555+#define I2CSTAT_TBF (1<<0)5656+5757+#define PIC32_I2CxADD 0x00205858+#define PIC32_I2CxADDCLR 0x00245959+#define PIC32_I2CxADDSET 0x00286060+#define PIC32_I2CxADDINV 0x002C6161+#define PIC32_I2CxMSK 0x00306262+#define PIC32_I2CxMSKCLR 0x00346363+#define PIC32_I2CxMSKSET 0x00386464+#define PIC32_I2CxMSKINV 0x003C6565+#define PIC32_I2CxBRG 0x00406666+#define PIC32_I2CxBRGCLR 0x00446767+#define PIC32_I2CxBRGSET 0x00486868+#define PIC32_I2CxBRGINV 0x004C6969+#define PIC32_I2CxTRN 0x00507070+#define PIC32_I2CxTRNCLR 0x00547171+#define PIC32_I2CxTRNSET 0x00587272+#define PIC32_I2CxTRNINV 0x005C7373+#define PIC32_I2CxRCV 0x00607474+7575+struct i2c_platform_data {7676+ u32 base;7777+ struct i2c_adapter adap;7878+ u32 xfer_timeout;7979+ u32 ack_timeout;8080+ u32 ctl_timeout;8181+};8282+8383+extern u32 pic32_bus_readl(u32 reg);8484+extern void pic32_bus_writel(u32 val, u32 reg);8585+8686+static inline void8787+StartI2C(struct i2c_platform_data *adap)8888+{8989+ pr_debug("StartI2C\n");9090+ pic32_bus_writel(I2CCON_SEN, adap->base + PIC32_I2CxCONSET);9191+}9292+9393+static inline void9494+StopI2C(struct i2c_platform_data *adap)9595+{9696+ pr_debug("StopI2C\n");9797+ pic32_bus_writel(I2CCON_PEN, adap->base + PIC32_I2CxCONSET);9898+}9999+100100+static inline void101101+AckI2C(struct i2c_platform_data *adap)102102+{103103+ pr_debug("AckI2C\n");104104+ pic32_bus_writel(I2CCON_ACKDT, adap->base + PIC32_I2CxCONCLR);105105+ pic32_bus_writel(I2CCON_ACKEN, adap->base + PIC32_I2CxCONSET);106106+}107107+108108+static inline void109109+NotAckI2C(struct i2c_platform_data *adap)110110+{111111+ pr_debug("NakI2C\n");112112+ pic32_bus_writel(I2CCON_ACKDT, adap->base + PIC32_I2CxCONSET);113113+ pic32_bus_writel(I2CCON_ACKEN, adap->base + PIC32_I2CxCONSET);114114+}115115+116116+static inline int117117+IdleI2C(struct i2c_platform_data *adap)118118+{119119+ int i;120120+121121+ pr_debug("IdleI2C\n");122122+ for (i = 0; i < adap->ctl_timeout; i++) {123123+ if (((pic32_bus_readl(adap->base + PIC32_I2CxCON) &124124+ (I2CCON_ACKEN | I2CCON_RCEN | I2CCON_PEN | I2CCON_RSEN |125125+ I2CCON_SEN)) == 0) &&126126+ ((pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &127127+ (I2CSTAT_TRSTAT)) == 0))128128+ return 0;129129+ udelay(1);130130+ }131131+ return -ETIMEDOUT;132132+}133133+134134+static inline u32135135+MasterWriteI2C(struct i2c_platform_data *adap, u32 byte)136136+{137137+ pr_debug("MasterWriteI2C\n");138138+139139+ pic32_bus_writel(byte, adap->base + PIC32_I2CxTRN);140140+141141+ return pic32_bus_readl(adap->base + PIC32_I2CxSTAT) & I2CSTAT_IWCOL;142142+}143143+144144+static inline u32145145+MasterReadI2C(struct i2c_platform_data *adap)146146+{147147+ pr_debug("MasterReadI2C\n");148148+149149+ pic32_bus_writel(I2CCON_RCEN, adap->base + PIC32_I2CxCONSET);150150+151151+ while (pic32_bus_readl(adap->base + PIC32_I2CxCON) & I2CCON_RCEN)152152+ ;153153+154154+ pic32_bus_writel(I2CSTAT_I2COV, adap->base + PIC32_I2CxSTATCLR);155155+156156+ return pic32_bus_readl(adap->base + PIC32_I2CxRCV);157157+}158158+159159+static int160160+do_address(struct i2c_platform_data *adap, unsigned int addr, int rd)161161+{162162+ pr_debug("doaddress\n");163163+164164+ IdleI2C(adap);165165+ StartI2C(adap);166166+ IdleI2C(adap);167167+168168+ addr <<= 1;169169+ if (rd)170170+ addr |= 1;171171+172172+ if (MasterWriteI2C(adap, addr))173173+ return -EIO;174174+ IdleI2C(adap);175175+ if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) & I2CSTAT_ACKSTAT)176176+ return -EIO;177177+ return 0;178178+}179179+180180+static int181181+i2c_read(struct i2c_platform_data *adap, unsigned char *buf,182182+ unsigned int len)183183+{184184+ int i;185185+ u32 data;186186+187187+ pr_debug("i2c_read\n");188188+189189+ i = 0;190190+ while (i < len) {191191+ data = MasterReadI2C(adap);192192+ buf[i++] = data;193193+ if (i < len)194194+ AckI2C(adap);195195+ else196196+ NotAckI2C(adap);197197+ }198198+199199+ StopI2C(adap);200200+ IdleI2C(adap);201201+ return 0;202202+}203203+204204+static int205205+i2c_write(struct i2c_platform_data *adap, unsigned char *buf,206206+ unsigned int len)207207+{208208+ int i;209209+ u32 data;210210+211211+ pr_debug("i2c_write\n");212212+213213+ i = 0;214214+ while (i < len) {215215+ data = buf[i];216216+ if (MasterWriteI2C(adap, data))217217+ return -EIO;218218+ IdleI2C(adap);219219+ if (pic32_bus_readl(adap->base + PIC32_I2CxSTAT) &220220+ I2CSTAT_ACKSTAT)221221+ return -EIO;222222+ i++;223223+ }224224+225225+ StopI2C(adap);226226+ IdleI2C(adap);227227+ return 0;228228+}229229+230230+static int231231+platform_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)232232+{233233+ struct i2c_platform_data *adap = i2c_adap->algo_data;234234+ struct i2c_msg *p;235235+ int i, err = 0;236236+237237+ pr_debug("platform_xfer\n");238238+ for (i = 0; i < num; i++) {239239+#define __BUFSIZE 80240240+ int ii;241241+ static char buf[__BUFSIZE];242242+ char *b = buf;243243+244244+ p = &msgs[i];245245+ b += sprintf(buf, " [%d bytes]", p->len);246246+ if ((p->flags & I2C_M_RD) == 0) {247247+ for (ii = 0; ii < p->len; ii++) {248248+ if (b < &buf[__BUFSIZE-4]) {249249+ b += sprintf(b, " %02x", p->buf[ii]);250250+ } else {251251+ strcat(b, "...");252252+ break;253253+ }254254+ }255255+ }256256+ pr_debug("xfer%d: DevAddr: %04x Op:%s Data:%s\n", i, p->addr,257257+ (p->flags & I2C_M_RD) ? "Rd" : "Wr", buf);258258+ }259259+260260+261261+ for (i = 0; !err && i < num; i++) {262262+ p = &msgs[i];263263+ err = do_address(adap, p->addr, p->flags & I2C_M_RD);264264+ if (err || !p->len)265265+ continue;266266+ if (p->flags & I2C_M_RD)267267+ err = i2c_read(adap, p->buf, p->len);268268+ else269269+ err = i2c_write(adap, p->buf, p->len);270270+ }271271+272272+ /* Return the number of messages processed, or the error code. */273273+ if (err == 0)274274+ err = num;275275+276276+ return err;277277+}278278+279279+static u32280280+platform_func(struct i2c_adapter *adap)281281+{282282+ pr_debug("platform_algo\n");283283+ return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;284284+}285285+286286+static const struct i2c_algorithm platform_algo = {287287+ .master_xfer = platform_xfer,288288+ .functionality = platform_func,289289+};290290+291291+static void i2c_platform_setup(struct i2c_platform_data *priv)292292+{293293+ pr_debug("i2c_platform_setup\n");294294+295295+ pic32_bus_writel(500, priv->base + PIC32_I2CxBRG);296296+ pic32_bus_writel(I2CCON_ON, priv->base + PIC32_I2CxCONCLR);297297+ pic32_bus_writel(I2CCON_ON, priv->base + PIC32_I2CxCONSET);298298+ pic32_bus_writel((I2CSTAT_BCL | I2CSTAT_IWCOL),299299+ (priv->base + PIC32_I2CxSTATCLR));300300+}301301+302302+static void i2c_platform_disable(struct i2c_platform_data *priv)303303+{304304+ pr_debug("i2c_platform_disable\n");305305+}306306+307307+static int __devinit308308+i2c_platform_probe(struct platform_device *pdev)309309+{310310+ struct i2c_platform_data *priv;311311+ struct resource *r;312312+ int ret;313313+314314+ pr_debug("i2c_platform_probe\n");315315+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);316316+ if (!r) {317317+ ret = -ENODEV;318318+ goto out;319319+ }320320+321321+ priv = kzalloc(sizeof(struct i2c_platform_data), GFP_KERNEL);322322+ if (!priv) {323323+ ret = -ENOMEM;324324+ goto out;325325+ }326326+327327+ /* FIXME: need to allocate resource in PIC32 space */328328+#if 0329329+ priv->base = bus_request_region(r->start, resource_size(r),330330+ pdev->name);331331+#else332332+ priv->base = r->start;333333+#endif334334+ if (!priv->base) {335335+ ret = -EBUSY;336336+ goto out_mem;337337+ }338338+339339+ priv->xfer_timeout = 200;340340+ priv->ack_timeout = 200;341341+ priv->ctl_timeout = 200;342342+343343+ priv->adap.nr = pdev->id;344344+ priv->adap.algo = &platform_algo;345345+ priv->adap.algo_data = priv;346346+ priv->adap.dev.parent = &pdev->dev;347347+ strlcpy(priv->adap.name, "PIC32 I2C", sizeof(priv->adap.name));348348+349349+ i2c_platform_setup(priv);350350+351351+ ret = i2c_add_numbered_adapter(&priv->adap);352352+ if (ret == 0) {353353+ platform_set_drvdata(pdev, priv);354354+ return 0;355355+ }356356+357357+ i2c_platform_disable(priv);358358+359359+out_mem:360360+ kfree(priv);361361+out:362362+ return ret;363363+}364364+365365+static int __devexit366366+i2c_platform_remove(struct platform_device *pdev)367367+{368368+ struct i2c_platform_data *priv = platform_get_drvdata(pdev);369369+370370+ pr_debug("i2c_platform_remove\n");371371+ platform_set_drvdata(pdev, NULL);372372+ i2c_del_adapter(&priv->adap);373373+ i2c_platform_disable(priv);374374+ kfree(priv);375375+ return 0;376376+}377377+378378+#ifdef CONFIG_PM379379+static int380380+i2c_platform_suspend(struct platform_device *pdev, pm_message_t state)381381+{382382+ struct i2c_platform_data *priv = platform_get_drvdata(pdev);383383+384384+ dev_dbg(&pdev->dev, "i2c_platform_disable\n");385385+ i2c_platform_disable(priv);386386+387387+ return 0;388388+}389389+390390+static int391391+i2c_platform_resume(struct platform_device *pdev)392392+{393393+ struct i2c_platform_data *priv = platform_get_drvdata(pdev);394394+395395+ dev_dbg(&pdev->dev, "i2c_platform_setup\n");396396+ i2c_platform_setup(priv);397397+398398+ return 0;399399+}400400+#else401401+#define i2c_platform_suspend NULL402402+#define i2c_platform_resume NULL403403+#endif404404+405405+static struct platform_driver i2c_platform_driver = {406406+ .driver = {407407+ .name = "i2c_pic32",408408+ .owner = THIS_MODULE,409409+ },410410+ .probe = i2c_platform_probe,411411+ .remove = __devexit_p(i2c_platform_remove),412412+ .suspend = i2c_platform_suspend,413413+ .resume = i2c_platform_resume,414414+};415415+416416+static int __init417417+i2c_platform_init(void)418418+{419419+ pr_debug("i2c_platform_init\n");420420+ return platform_driver_register(&i2c_platform_driver);421421+}422422+423423+static void __exit424424+i2c_platform_exit(void)425425+{426426+ pr_debug("i2c_platform_exit\n");427427+ platform_driver_unregister(&i2c_platform_driver);428428+}429429+430430+MODULE_AUTHOR("Chris Dearman, MIPS Technologies INC.");431431+MODULE_DESCRIPTION("PIC32 I2C driver");432432+MODULE_LICENSE("GPL");433433+434434+module_init(i2c_platform_init);435435+module_exit(i2c_platform_exit);
+45
arch/mips/mti-sead3/sead3-platform.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/init.h>1010+#include <linux/serial_8250.h>1111+1212+#define UART(base, int) \1313+{ \1414+ .mapbase = base, \1515+ .irq = int, \1616+ .uartclk = 14745600, \1717+ .iotype = UPIO_MEM32, \1818+ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \1919+ .regshift = 2, \2020+}2121+2222+static struct plat_serial8250_port uart8250_data[] = {2323+ UART(0x1f000900, MIPS_CPU_IRQ_BASE + 4), /* ttyS0 = USB */2424+ UART(0x1f000800, MIPS_CPU_IRQ_BASE + 4), /* ttyS1 = RS232 */2525+ { },2626+};2727+2828+static struct platform_device uart8250_device = {2929+ .name = "serial8250",3030+ .id = PLAT8250_DEV_PLATFORM2,3131+ .dev = {3232+ .platform_data = uart8250_data,3333+ },3434+};3535+3636+static int __init uart8250_init(void)3737+{3838+ return platform_device_register(&uart8250_device);3939+}4040+4141+module_init(uart8250_init);4242+4343+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");4444+MODULE_LICENSE("GPL");4545+MODULE_DESCRIPTION("8250 UART probe driver for SEAD3");
+39
arch/mips/mti-sead3/sead3-reset.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/io.h>99+#include <linux/pm.h>1010+1111+#include <asm/reboot.h>1212+#include <asm/mips-boards/generic.h>1313+1414+static void mips_machine_restart(char *command)1515+{1616+ unsigned int __iomem *softres_reg =1717+ ioremap(SOFTRES_REG, sizeof(unsigned int));1818+1919+ __raw_writel(GORESET, softres_reg);2020+}2121+2222+static void mips_machine_halt(void)2323+{2424+ unsigned int __iomem *softres_reg =2525+ ioremap(SOFTRES_REG, sizeof(unsigned int));2626+2727+ __raw_writel(GORESET, softres_reg);2828+}2929+3030+static int __init mips_reboot_setup(void)3131+{3232+ _machine_restart = mips_machine_restart;3333+ _machine_halt = mips_machine_halt;3434+ pm_power_off = mips_machine_halt;3535+3636+ return 0;3737+}3838+3939+arch_initcall(mips_reboot_setup);
+45
arch/mips/mti-sead3/sead3-serial.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/module.h>99+#include <linux/init.h>1010+#include <linux/serial_8250.h>1111+1212+#define UART(base, int) \1313+{ \1414+ .mapbase = base, \1515+ .irq = int, \1616+ .uartclk = 14745600, \1717+ .iotype = UPIO_MEM32, \1818+ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \1919+ .regshift = 2, \2020+}2121+2222+static struct plat_serial8250_port uart8250_data[] = {2323+ UART(0x1f000900, MIPS_CPU_IRQ_BASE + 4), /* ttyS0 = USB */2424+ UART(0x1f000800, MIPS_CPU_IRQ_BASE + 4), /* ttyS1 = RS232 */2525+ { },2626+};2727+2828+static struct platform_device uart8250_device = {2929+ .name = "serial8250",3030+ .id = PLAT8250_DEV_PLATFORM,3131+ .dev = {3232+ .platform_data = uart8250_data,3333+ },3434+};3535+3636+static int __init uart8250_init(void)3737+{3838+ return platform_device_register(&uart8250_device);3939+}4040+4141+module_init(uart8250_init);4242+4343+MODULE_AUTHOR("Chris Dearman <chris@mips.com>");4444+MODULE_LICENSE("GPL");4545+MODULE_DESCRIPTION("8250 UART probe driver for the SEAD-3 platform");
+20
arch/mips/mti-sead3/sead3-setup.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+1010+int coherentio; /* 0 => no DMA cache coherency (may be set by user) */1111+int hw_coherentio; /* 0 => no HW DMA cache coherency (reflects real HW) */1212+1313+const char *get_system_type(void)1414+{1515+ return "MIPS SEAD3";1616+}1717+1818+void __init plat_mem_setup(void)1919+{2020+}
+117
arch/mips/mti-sead3/sead3-time.c
···11+/*22+ * This file is subject to the terms and conditions of the GNU General Public33+ * License. See the file "COPYING" in the main directory of this archive44+ * for more details.55+ *66+ * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.77+ */88+#include <linux/init.h>99+1010+#include <asm/setup.h>1111+#include <asm/time.h>1212+#include <asm/irq.h>1313+#include <asm/mips-boards/generic.h>1414+#include <asm/mips-boards/prom.h>1515+1616+unsigned long cpu_khz;1717+1818+static int mips_cpu_timer_irq;1919+static int mips_cpu_perf_irq;2020+2121+static void mips_timer_dispatch(void)2222+{2323+ do_IRQ(mips_cpu_timer_irq);2424+}2525+2626+static void mips_perf_dispatch(void)2727+{2828+ do_IRQ(mips_cpu_perf_irq);2929+}3030+3131+static void __iomem *status_reg = (void __iomem *)0xbf000410;3232+3333+/*3434+ * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect.3535+ */3636+static unsigned int __init estimate_cpu_frequency(void)3737+{3838+ unsigned int prid = read_c0_prid() & 0xffff00;3939+ unsigned int tick = 0;4040+ unsigned int freq;4141+ unsigned int orig;4242+ unsigned long flags;4343+4444+ local_irq_save(flags);4545+4646+ orig = readl(status_reg) & 0x2; /* get original sample */4747+ /* wait for transition */4848+ while ((readl(status_reg) & 0x2) == orig)4949+ ;5050+ orig = orig ^ 0x2; /* flip the bit */5151+5252+ write_c0_count(0);5353+5454+ /* wait 1 second (the sampling clock transitions every 10ms) */5555+ while (tick < 100) {5656+ /* wait for transition */5757+ while ((readl(status_reg) & 0x2) == orig)5858+ ;5959+ orig = orig ^ 0x2; /* flip the bit */6060+ tick++;6161+ }6262+6363+ freq = read_c0_count();6464+6565+ local_irq_restore(flags);6666+6767+ mips_hpt_frequency = freq;6868+6969+ /* Adjust for processor */7070+ if ((prid != (PRID_COMP_MIPS | PRID_IMP_20KC)) &&7171+ (prid != (PRID_COMP_MIPS | PRID_IMP_25KF)))7272+ freq *= 2;7373+7474+ freq += 5000; /* rounding */7575+ freq -= freq%10000;7676+7777+ return freq ;7878+}7979+8080+void read_persistent_clock(struct timespec *ts)8181+{8282+ ts->tv_sec = 0;8383+ ts->tv_nsec = 0;8484+}8585+8686+static void __init plat_perf_setup(void)8787+{8888+ if (cp0_perfcount_irq >= 0) {8989+ if (cpu_has_vint)9090+ set_vi_handler(cp0_perfcount_irq, mips_perf_dispatch);9191+ mips_cpu_perf_irq = MIPS_CPU_IRQ_BASE + cp0_perfcount_irq;9292+ }9393+}9494+9595+unsigned int __cpuinit get_c0_compare_int(void)9696+{9797+ if (cpu_has_vint)9898+ set_vi_handler(cp0_compare_irq, mips_timer_dispatch);9999+ mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;100100+ return mips_cpu_timer_irq;101101+}102102+103103+void __init plat_time_init(void)104104+{105105+ unsigned int est_freq;106106+107107+ est_freq = estimate_cpu_frequency();108108+109109+ pr_debug("CPU frequency %d.%02d MHz\n", (est_freq / 1000000),110110+ (est_freq % 1000000) * 100 / 1000000);111111+112112+ cpu_khz = est_freq / 1000;113113+114114+ mips_scroll_message();115115+116116+ plat_perf_setup();117117+}