1 /* $Id: at91rm9200bus.c,v 1.2 2008/07/03 01:15:38 matt Exp $ */
4 __KERNEL_RCSID(0, "$NetBSD$");
9 #include <sys/kernel.h>
11 #include <sys/device.h>
12 #include <uvm/uvm_extern.h>
14 #include <arm/at91/at91rm9200busvar.h>
16 const struct at91bus_machdep at91rm9200bus
= {
18 at91rm9200bus_attach_cn
,
21 /* clocking support: */
22 at91rm9200bus_peripheral_clock
,
25 at91rm9200bus_pio_port
,
26 at91rm9200bus_gpio_mask
,
28 /* interrupt handling support: */
29 at91rm9200bus_intr_init
,
30 at91rm9200bus_intr_establish
,
31 at91rm9200bus_intr_disestablish
,
32 at91rm9200bus_intr_poll
,
33 at91rm9200bus_intr_dispatch
,
36 at91rm9200bus_peripheral_name
,
37 at91rm9200bus_search_peripherals
40 void at91rm9200bus_init(struct at91bus_clocks
*clocks
)
42 pmap_devmap_register(at91_devmap());
43 at91pmc_get_clocks(clocks
);
46 const struct pmap_devmap
*at91rm9200bus_devmap(void)
48 static const struct pmap_devmap devmap
[] = {
51 AT91RM9200_APB_HWBASE
,
53 VM_PROT_READ
| VM_PROT_WRITE
,
69 void at91rm9200bus_peripheral_clock(int pid
, int enable
)
74 PMCREG(PMC_SCER
) = PMC_SCSR_UHP
;
76 PMCREG(PMC_SCDR
) = PMC_SCSR_UHP
;
79 at91pmc_peripheral_clock(pid
, enable
);
82 at91pio_port
at91rm9200bus_pio_port(int pid
)
85 case PID_PIOA
: return AT91_PIOA
;
86 case PID_PIOB
: return AT91_PIOB
;
87 case PID_PIOC
: return AT91_PIOC
;
88 case PID_PIOD
: return AT91_PIOD
;
89 default: panic("%s: pid %d not valid", __FUNCTION__
, pid
);
94 uint32_t at91rm9200bus_gpio_mask(int pid
)
99 const char *at91rm9200bus_peripheral_name(int pid
)
102 case PID_FIQ
: return "FIQ";
103 case PID_SYSIRQ
:return "SYS";
104 case PID_PIOA
: return "PIOA";
105 case PID_PIOB
: return "PIOB";
106 case PID_PIOC
: return "PIOC";
107 case PID_PIOD
: return "PIOD";
108 case PID_US0
: return "USART0";
109 case PID_US1
: return "USART1";
110 case PID_US2
: return "USART2";
111 case PID_US3
: return "USART3";
112 case PID_MCI
: return "MCI";
113 case PID_UDP
: return "UDP";
114 case PID_TWI
: return "TWI";
115 case PID_SPI
: return "SPI";
116 case PID_SSC0
: return "SSC0";
117 case PID_SSC1
: return "SSC1";
118 case PID_SSC2
: return "SSC2";
119 case PID_TC0
: return "TC0";
120 case PID_TC1
: return "TC1";
121 case PID_TC2
: return "TC2";
122 case PID_TC3
: return "TC3";
123 case PID_TC4
: return "TC4";
124 case PID_TC5
: return "TC5";
125 case PID_UHP
: return "UHP";
126 case PID_EMAC
: return "EMAC";
127 case PID_IRQ0
: return "IRQ0";
128 case PID_IRQ1
: return "IRQ1";
129 case PID_IRQ2
: return "IRQ2";
130 case PID_IRQ3
: return "IRQ3";
131 case PID_IRQ4
: return "IRQ4";
132 case PID_IRQ5
: return "IRQ5";
133 case PID_IRQ6
: return "IRQ6";
134 default: panic("%s: invalid pid %d", __FUNCTION__
, pid
);
138 void at91rm9200bus_search_peripherals(device_t self
,
139 device_t (*found_func
)(device_t
, bus_addr_t
, int))
141 static const struct {
145 {AT91RM9200_PMC_BASE
, -1},
146 {AT91RM9200_AIC_BASE
, -1},
147 {AT91RM9200_ST_BASE
, PID_SYSIRQ
},
148 {AT91RM9200_TC0_BASE
, PID_TC0
},
149 {AT91RM9200_TC1_BASE
, PID_TC1
},
150 {AT91RM9200_TC2_BASE
, PID_TC2
},
151 {AT91RM9200_TC3_BASE
, PID_TC3
},
152 {AT91RM9200_TC4_BASE
, PID_TC4
},
153 {AT91RM9200_TC5_BASE
, PID_TC5
},
154 {AT91RM9200_DBGU_BASE
, PID_SYSIRQ
},
155 {AT91RM9200_PIOA_BASE
, PID_PIOA
},
156 {AT91RM9200_PIOB_BASE
, PID_PIOB
},
157 {AT91RM9200_PIOC_BASE
, PID_PIOC
},
158 {AT91RM9200_PIOD_BASE
, PID_PIOD
},
159 {AT91RM9200_USART0_BASE
, PID_US0
},
160 {AT91RM9200_USART1_BASE
, PID_US1
},
161 {AT91RM9200_USART2_BASE
, PID_US2
},
162 {AT91RM9200_USART3_BASE
, PID_US3
},
163 {AT91RM9200_SSC0_BASE
, PID_SSC0
},
164 {AT91RM9200_SSC1_BASE
, PID_SSC1
},
165 {AT91RM9200_SSC2_BASE
, PID_SSC2
},
166 {AT91RM9200_TWI_BASE
, PID_TWI
},
167 {AT91RM9200_SPI_BASE
, PID_SPI
},
168 {AT91RM9200_EMAC_BASE
, PID_EMAC
},
169 {AT91RM9200_UHP_BASE
, PID_UHP
},
170 {AT91RM9200_UDP_BASE
, PID_UDP
},
171 {AT91RM9200_MCI_BASE
, PID_MCI
},
172 {AT91RM9200_RTC_BASE
, PID_SYSIRQ
},
177 for (i
= 0; table
[i
].addr
; i
++)
178 (*found_func
)(self
, table
[i
].addr
, table
[i
].pid
);