iodi.c (198160) | iodi.c (198607) |
---|---|
1/*- 2 * Copyright (c) 2003-2009 RMI Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 32 unchanged lines hidden (view full) --- 41#include <sys/bus.h> 42#include <sys/interrupt.h> 43#include <sys/module.h> 44 45#include <machine/cpu.h> 46#include <machine/bus.h> 47#include <machine/bus.h> 48#include <machine/intr_machdep.h> | 1/*- 2 * Copyright (c) 2003-2009 RMI Corporation 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 32 unchanged lines hidden (view full) --- 41#include <sys/bus.h> 42#include <sys/interrupt.h> 43#include <sys/module.h> 44 45#include <machine/cpu.h> 46#include <machine/bus.h> 47#include <machine/bus.h> 48#include <machine/intr_machdep.h> |
49#include <mips/xlr/iomap.h> 50#include <mips/xlr/pic.h> 51#include <mips/xlr/board.h> | 49#include <mips/rmi/iomap.h> 50#include <mips/rmi/pic.h> 51#include <mips/rmi/shared_structs.h> 52#include <mips/rmi/board.h> |
52#include <sys/rman.h> 53 | 53#include <sys/rman.h> 54 |
55 56#include <machine/param.h> 57#include <machine/intr_machdep.h> 58#include <machine/clock.h> /* for DELAY */ 59#include <machine/bus.h> 60#include <machine/resource.h> 61#include <mips/rmi/interrupt.h> 62#include <mips/rmi/msgring.h> 63#include <mips/rmi/iomap.h> 64#include <mips/rmi/debug.h> 65#include <mips/rmi/pic.h> 66#include <mips/rmi/xlrconfig.h> 67#include <mips/rmi/shared_structs.h> 68#include <mips/rmi/board.h> 69 70#include <dev/rmi/xlr/atx_cpld.h> 71#include <dev/rmi/xlr/xgmac_mdio.h> 72 |
|
54extern void iodi_activateirqs(void); 55 56extern bus_space_tag_t uart_bus_space_mem; 57 58static struct resource *iodi_alloc_resource(device_t, device_t, int, int *, 59 u_long, u_long, u_long, u_int); 60 61static int iodi_activate_resource(device_t, device_t, int, int, 62 struct resource *); 63static int iodi_setup_intr(device_t, device_t, struct resource *, int, | 73extern void iodi_activateirqs(void); 74 75extern bus_space_tag_t uart_bus_space_mem; 76 77static struct resource *iodi_alloc_resource(device_t, device_t, int, int *, 78 u_long, u_long, u_long, u_int); 79 80static int iodi_activate_resource(device_t, device_t, int, int, 81 struct resource *); 82static int iodi_setup_intr(device_t, device_t, struct resource *, int, |
64 driver_intr_t *, void *, void **); | 83 driver_filter_t *, driver_intr_t *, void *, void **); |
65 66struct iodi_softc *iodi_softc; /* There can be only one. */ 67 | 84 85struct iodi_softc *iodi_softc; /* There can be only one. */ 86 |
87/* |
|
68static void pic_usb_ack(void *arg) 69{ 70 xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET); 71 int irq = PIC_USB_IRQ ; 72 73 mtx_lock_spin(&xlr_pic_lock); 74 xlr_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE))); 75 mtx_unlock_spin(&xlr_pic_lock); 76} | 88static void pic_usb_ack(void *arg) 89{ 90 xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET); 91 int irq = PIC_USB_IRQ ; 92 93 mtx_lock_spin(&xlr_pic_lock); 94 xlr_write_reg(mmio, PIC_INT_ACK, (1 << (irq - PIC_IRQ_BASE))); 95 mtx_unlock_spin(&xlr_pic_lock); 96} |
97*/ |
|
77 78static int 79iodi_setup_intr(device_t dev, device_t child, | 98 99static int 100iodi_setup_intr(device_t dev, device_t child, |
80 struct resource *ires, int flags, driver_intr_t *intr, void *arg, | 101 struct resource *ires, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, |
81 void **cookiep) 82{ 83 int level; 84 xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET); 85 xlr_reg_t reg; 86 87 /* FIXME is this the right place to fiddle with PIC? */ 88 if (strcmp(device_get_name(child),"uart") == 0) { 89 /* FIXME uart 1? */ 90 mtx_lock_spin(&xlr_pic_lock); 91 level = PIC_IRQ_IS_EDGE_TRIGGERED(PIC_IRT_UART_0_INDEX); 92 xlr_write_reg(mmio, PIC_IRT_0_UART_0, 0x01); 93 xlr_write_reg(mmio, PIC_IRT_1_UART_0, ((1 << 31) | (level<<30)|(1<<6)|(PIC_UART_0_IRQ))); 94 mtx_unlock_spin(&xlr_pic_lock); | 102 void **cookiep) 103{ 104 int level; 105 xlr_reg_t *mmio = xlr_io_mmio(XLR_IO_PIC_OFFSET); 106 xlr_reg_t reg; 107 108 /* FIXME is this the right place to fiddle with PIC? */ 109 if (strcmp(device_get_name(child),"uart") == 0) { 110 /* FIXME uart 1? */ 111 mtx_lock_spin(&xlr_pic_lock); 112 level = PIC_IRQ_IS_EDGE_TRIGGERED(PIC_IRT_UART_0_INDEX); 113 xlr_write_reg(mmio, PIC_IRT_0_UART_0, 0x01); 114 xlr_write_reg(mmio, PIC_IRT_1_UART_0, ((1 << 31) | (level<<30)|(1<<6)|(PIC_UART_0_IRQ))); 115 mtx_unlock_spin(&xlr_pic_lock); |
116 cpu_establish_hardintr("uart", NULL, 117 (driver_intr_t *)intr, (void *)arg, PIC_UART_0_IRQ, flags, cookiep); |
|
95 | 118 |
96 cpu_establish_intr("uart", PIC_UART_0_IRQ, 97 (driver_intr_t *)intr, (void *)arg, flags, cookiep, 98 NULL, NULL); 99 | |
100 } else if (strcmp(device_get_name(child),"rge") == 0) { | 119 } else if (strcmp(device_get_name(child),"rge") == 0) { |
120 int irq; 121 irq = rman_get_rid(ires); |
|
101 mtx_lock_spin(&xlr_pic_lock); | 122 mtx_lock_spin(&xlr_pic_lock); |
102 reg = xlr_read_reg(mmio, PIC_IRT_1_BASE + ires->r_flags - PIC_IRQ_BASE); 103 xlr_write_reg(mmio, PIC_IRT_1_BASE + ires->r_flags - PIC_IRQ_BASE, reg | (1<<6)|(1<<30)| (1<<31)); | 123 reg = xlr_read_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE); 124 xlr_write_reg(mmio, PIC_IRT_1_BASE + irq - PIC_IRQ_BASE, reg | (1<<6)|(1<<30)| (1<<31)); |
104 mtx_unlock_spin(&xlr_pic_lock); | 125 mtx_unlock_spin(&xlr_pic_lock); |
105 cpu_establish_intr("rge", ires->r_flags, 106 (driver_intr_t *)intr, (void *)arg, 107 flags, cookiep, NULL, NULL); | 126 cpu_establish_hardintr("rge", NULL, (driver_intr_t *)intr, (void *)arg, irq, flags, cookiep); 127 |
108 } else if (strcmp(device_get_name(child),"ehci") == 0) { 109 mtx_lock_spin(&xlr_pic_lock); 110 reg = xlr_read_reg(mmio, PIC_IRT_1_BASE + PIC_USB_IRQ - PIC_IRQ_BASE); 111 xlr_write_reg(mmio, PIC_IRT_1_BASE + PIC_USB_IRQ - PIC_IRQ_BASE, reg | (1<<6)|(1<<30)| (1<<31)); 112 mtx_unlock_spin(&xlr_pic_lock); | 128 } else if (strcmp(device_get_name(child),"ehci") == 0) { 129 mtx_lock_spin(&xlr_pic_lock); 130 reg = xlr_read_reg(mmio, PIC_IRT_1_BASE + PIC_USB_IRQ - PIC_IRQ_BASE); 131 xlr_write_reg(mmio, PIC_IRT_1_BASE + PIC_USB_IRQ - PIC_IRQ_BASE, reg | (1<<6)|(1<<30)| (1<<31)); 132 mtx_unlock_spin(&xlr_pic_lock); |
113 cpu_establish_intr("ehci", PIC_USB_IRQ, 114 (driver_intr_t *)intr, (void *)arg, 115 flags, cookiep, (flags & INTR_FAST)? NULL: pic_usb_ack , NULL); | 133 cpu_establish_hardintr("ehci", NULL, (driver_intr_t *)intr, (void *)arg, PIC_USB_IRQ, flags, cookiep); |
116 } 117 | 134 } 135 |
118 BUS_SETUP_INTR(device_get_parent(dev), child, ires, flags, intr, arg, 119 cookiep); | 136 BUS_SETUP_INTR(device_get_parent(dev), 137 child, ires, flags, filt, intr, arg, cookiep); 138 139 |
120 return (0); 121} 122 | 140 return (0); 141} 142 |
143/* Strange hook found in mips/include/bus.h */ 144#ifndef MIPS_BUS_SPACE_PCI 145#define MIPS_BUS_SPACE_PCI 10 146#endif 147 |
|
123static struct resource * 124iodi_alloc_resource(device_t bus, device_t child, int type, int *rid, 125 u_long start, u_long end, u_long count, u_int flags) 126{ 127 struct resource *res = malloc(sizeof(*res), M_DEVBUF, M_WAITOK); 128 int unit; 129 130#ifdef DEBUG --- 23 unchanged lines hidden (view full) --- 154 res->r_bushandle = (xlr_io_base + XLR_IO_UART_1_OFFSET); 155 } 156 else 157 printf("%s: Unknown uart unit\n", __FUNCTION__); 158 159 res->r_bustag = uart_bus_space_mem; 160 } else if (strcmp(device_get_name(child),"ehci") == 0) { 161 res->r_bushandle = 0xbef24000; | 148static struct resource * 149iodi_alloc_resource(device_t bus, device_t child, int type, int *rid, 150 u_long start, u_long end, u_long count, u_int flags) 151{ 152 struct resource *res = malloc(sizeof(*res), M_DEVBUF, M_WAITOK); 153 int unit; 154 155#ifdef DEBUG --- 23 unchanged lines hidden (view full) --- 179 res->r_bushandle = (xlr_io_base + XLR_IO_UART_1_OFFSET); 180 } 181 else 182 printf("%s: Unknown uart unit\n", __FUNCTION__); 183 184 res->r_bustag = uart_bus_space_mem; 185 } else if (strcmp(device_get_name(child),"ehci") == 0) { 186 res->r_bushandle = 0xbef24000; |
162 res->r_bustag = MIPS_BUS_SPACE_PCI; | 187 res->r_bustag = (bus_space_tag_t)MIPS_BUS_SPACE_PCI; |
163 } else if (strcmp(device_get_name(child),"cfi") == 0) { 164 res->r_bushandle = 0xbc000000; 165 res->r_bustag = 0; 166 } | 188 } else if (strcmp(device_get_name(child),"cfi") == 0) { 189 res->r_bushandle = 0xbc000000; 190 res->r_bustag = 0; 191 } |
167 res->r_start = *rid; | 192 /*res->r_start = *rid;*/ |
168 return (res); 169} 170 171static int 172iodi_activate_resource(device_t bus, device_t child, int type, int rid, 173 struct resource *r) 174{ 175 return (0); --- 97 unchanged lines hidden --- | 193 return (res); 194} 195 196static int 197iodi_activate_resource(device_t bus, device_t child, int type, int rid, 198 struct resource *r) 199{ 200 return (0); --- 97 unchanged lines hidden --- |