Changeset ec08286 in mainline
- Timestamp:
- 2010-07-25T14:35:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 277cf60
- Parents:
- 24697c3
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r24697c3 rec08286 441 441 ! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_UART (y/n) 442 442 443 % Support for Samsung S3C24XX on-chip interrupt controller 444 ! [PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_IRQC (y) 445 443 446 % Support for Z8530 controller 444 447 ! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=keyboard)&PLATFORM=sparc64&MACHINE=generic] CONFIG_Z8530 (y/n) … … 469 472 470 473 % Serial line input module 471 ! [CONFIG_DSRLNIN=y|(PLATFORM= ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&MACHINE=serengeti&CONFIG_SGCN_KBD=y)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y)474 ! [CONFIG_DSRLNIN=y|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&MACHINE=serengeti&CONFIG_SGCN_KBD=y)|(PLATFORM=sparc64&PROCESSOR=sun4v)] CONFIG_SRLN (y) 472 475 473 476 % EGA support -
kernel/arch/arm32/src/mach/gta02/gta02.c
r24697c3 rec08286 43 43 #include <genarch/drivers/s3c24xx_irqc/s3c24xx_irqc.h> 44 44 #include <genarch/drivers/s3c24xx_timer/s3c24xx_timer.h> 45 #include <genarch/srln/srln.h> 45 46 #include <interrupt.h> 46 47 #include <ddi/ddi.h> … … 75 76 76 77 static void *gta02_scons_out; 77 static s3c24xx_irqc_t *gta02_irqc; 78 static outdev_t *gta02_scons_dev; 79 static s3c24xx_irqc_t gta02_irqc; 78 80 static s3c24xx_timer_t *gta02_timer; 79 81 … … 93 95 static void gta02_init(void) 94 96 { 97 s3c24xx_irqc_regs_t *irqc_regs; 98 95 99 gta02_scons_out = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE); 96 gta02_irqc = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE);97 100 gta02_timer = (void *) hw_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE); 98 99 /* Make all interrupt sources use IRQ mode (not FIQ). */ 100 pio_write_32(>a02_irqc->intmod, 0x00000000); 101 102 /* Disable all interrupt sources. */ 103 pio_write_32(>a02_irqc->intmsk, 0xffffffff); 104 105 /* Disable interrupts from all sub-sources. */ 106 pio_write_32(>a02_irqc->intsubmsk, 0xffffffff); 101 irqc_regs = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE); 102 103 /* Initialize interrupt controller. */ 104 s3c24xx_irqc_init(>a02_irqc, irqc_regs); 107 105 } 108 106 … … 132 130 uint32_t inum; 133 131 134 inum = pio_read_32(>a02_irqc->intoffset); 132 /* Determine IRQ number. */ 133 inum = s3c24xx_irqc_inum_get(>a02_irqc); 134 135 /* Clear interrupt condition in the interrupt controller. */ 136 s3c24xx_irqc_clear(>a02_irqc, inum); 135 137 136 138 irq_t *irq = irq_dispatch_and_lock(inum); … … 144 146 CPU->id, inum); 145 147 } 146 147 /* Clear interrupt condition in the interrupt controller. */148 pio_write_32(>a02_irqc->srcpnd, S3C24XX_INT_BIT(inum));149 pio_write_32(>a02_irqc->intpnd, S3C24XX_INT_BIT(inum));150 148 } 151 149 … … 176 174 } 177 175 #endif 178 outdev_t *scons_dev; 179 180 scons_dev = s3c24xx_uart_init((ioport8_t *) gta02_scons_out); 181 if (scons_dev) 182 stdout_wire(scons_dev); 176 177 /* Initialize serial port of the debugging console. */ 178 gta02_scons_dev = s3c24xx_uart_init((ioport8_t *) gta02_scons_out, 179 S3C24XX_INT_UART2); 180 if (gta02_scons_dev) { 181 182 /* Create output device. */ 183 stdout_wire(gta02_scons_dev); 184 } 183 185 } 184 186 185 187 static void gta02_input_init(void) 186 188 { 189 s3c24xx_uart_instance_t *scons_inst; 190 191 if (gta02_scons_dev) { 192 /* Create input device. */ 193 scons_inst = (void *) gta02_scons_dev->data; 194 195 srln_instance_t *srln_instance = srln_init(); 196 if (srln_instance) { 197 indev_t *sink = stdin_wire(); 198 indev_t *srln = srln_wire(srln_instance, sink); 199 s3c24xx_uart_input_wire(scons_inst, srln); 200 201 /* Enable interrupts from UART2 */ 202 s3c24xx_irqc_src_enable(>a02_irqc, 203 S3C24XX_INT_UART2); 204 205 /* Enable interrupts from UART2 RXD */ 206 s3c24xx_irqc_subsrc_enable(>a02_irqc, 207 S3C24XX_SUBINT_RXD2); 208 } 209 } 187 210 } 188 211 … … 248 271 249 272 /* Enable interrupts from timer0 */ 250 pio_write_32(>a02_irqc->intmsk, pio_read_32(>a02_irqc->intmsk) & 251 ~S3C24XX_INT_BIT(S3C24XX_INT_TIMER0)); 273 s3c24xx_irqc_src_enable(>a02_irqc, S3C24XX_INT_TIMER0); 252 274 253 275 /* Load data from tcntb0/tcmpb0 into tcnt0/tcmp0. */ -
kernel/genarch/Makefile.inc
r24697c3 rec08286 90 90 endif 91 91 92 ifeq ($(CONFIG_S3C24XX_IRQC),y) 93 GENARCH_SOURCES += \ 94 genarch/src/drivers/s3c24xx_irqc/s3c24xx_irqc.c 95 endif 96 92 97 ifeq ($(CONFIG_S3C24XX_UART),y) 93 98 GENARCH_SOURCES += \ -
kernel/genarch/include/drivers/s3c24xx_irqc/s3c24xx_irqc.h
r24697c3 rec08286 53 53 ioport32_t subsrcpnd; /**< Sub source pending */ 54 54 ioport32_t intsubmsk; /** Interrupt sub mask */ 55 } s3c24xx_irqc_ t;55 } s3c24xx_irqc_regs_t; 56 56 57 57 /** S3C24xx Interrupt source numbers. … … 120 120 #define S3C24XX_SUBINT_BIT(subsource) (1 << (subsource)) 121 121 122 typedef struct { 123 s3c24xx_irqc_regs_t *regs; 124 } s3c24xx_irqc_t; 125 126 extern void s3c24xx_irqc_init(s3c24xx_irqc_t *, s3c24xx_irqc_regs_t *); 127 extern unsigned s3c24xx_irqc_inum_get(s3c24xx_irqc_t *); 128 extern void s3c24xx_irqc_clear(s3c24xx_irqc_t *, unsigned); 129 extern void s3c24xx_irqc_src_enable(s3c24xx_irqc_t *, unsigned); 130 extern void s3c24xx_irqc_src_disable(s3c24xx_irqc_t *, unsigned); 131 extern void s3c24xx_irqc_subsrc_enable(s3c24xx_irqc_t *, unsigned); 132 extern void s3c24xx_irqc_subsrc_disable(s3c24xx_irqc_t *, unsigned); 133 122 134 #endif 123 135 -
kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h
r24697c3 rec08286 38 38 #define KERN_S3C24XX_UART_H_ 39 39 40 #include <ddi/irq.h> 41 #include <console/chardev.h> 40 42 #include <typedefs.h> 41 #include <console/chardev.h>42 43 43 extern outdev_t *s3c24xx_uart_init(ioport8_t *); 44 typedef struct { 45 ioport8_t *base; 46 indev_t *indev; 47 irq_t irq; 48 } s3c24xx_uart_instance_t; 49 50 extern outdev_t *s3c24xx_uart_init(ioport8_t *, inr_t inr); 51 extern void s3c24xx_uart_input_wire(s3c24xx_uart_instance_t *, 52 indev_t *); 44 53 45 54 #endif -
kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c
r24697c3 rec08286 40 40 #include <genarch/drivers/s3c24xx_uart/s3c24xx_uart.h> 41 41 #include <console/chardev.h> 42 #include <console/console.h> 43 #include <ddi/device.h> 42 44 #include <arch/asm.h> 43 45 #include <mm/slab.h> 44 #include <console/console.h>45 46 #include <sysinfo/sysinfo.h> 46 47 #include <str.h> 47 48 48 49 /** S3C24xx UART register offsets */ 49 #define S3C24XX_UTRSTAT 0x10 50 #define S3C24XX_UTXH 0x20 50 #define S3C24XX_ULCON 0x00 51 #define S3C24XX_UCON 0x04 52 #define S3C24XX_UFCON 0x08 53 #define S3C24XX_UMCON 0x0c 54 #define S3C24XX_UTRSTAT 0x10 55 #define S3C24XX_UERSTAT 0x14 56 #define S3C24XX_UFSTAT 0x18 57 #define S3C24XX_UMSTAT 0x1c 58 #define S3C24XX_UTXH 0x20 59 #define S3C24XX_URXH 0x24 60 #define S3C24XX_UBRDIV 0x28 51 61 52 /* Bits in UTXH register */ 53 #define S3C24XX_UTXH_TX_EMPTY 0x4 54 55 typedef struct { 56 ioport8_t *base; 57 } s3c24xx_uart_instance_t; 62 /* Bits in UTRSTAT register */ 63 #define S3C24XX_UTRSTAT_TX_EMPTY 0x4 64 #define S3C24XX_UTRSTAT_RDATA 0x1 58 65 59 66 static void s3c24xx_uart_sendb(outdev_t *dev, uint8_t byte) … … 67 74 68 75 /* Wait for transmitter to be empty. */ 69 while ((pio_read_32(utrstat) & S3C24XX_UT XH_TX_EMPTY) == 0)76 while ((pio_read_32(utrstat) & S3C24XX_UTRSTAT_TX_EMPTY) == 0) 70 77 ; 71 78 … … 86 93 } 87 94 95 static irq_ownership_t s3c24xx_uart_claim(irq_t *irq) 96 { 97 return IRQ_ACCEPT; 98 } 99 100 static void s3c24xx_uart_irq_handler(irq_t *irq) 101 { 102 s3c24xx_uart_instance_t *instance = irq->instance; 103 ioport32_t *utrstat, *urxh; 104 105 utrstat = (ioport32_t *) (instance->base + S3C24XX_UTRSTAT); 106 urxh = (ioport32_t *) (instance->base + S3C24XX_URXH); 107 108 if ((pio_read_32(utrstat) & S3C24XX_UTRSTAT_RDATA) != 0) { 109 uint32_t data = pio_read_32(urxh); 110 indev_push_character(instance->indev, data & 0xff); 111 } 112 } 113 88 114 static outdev_operations_t s3c24xx_uart_ops = { 89 115 .write = s3c24xx_uart_putchar, … … 91 117 }; 92 118 93 outdev_t *s3c24xx_uart_init(ioport8_t *base )119 outdev_t *s3c24xx_uart_init(ioport8_t *base, inr_t inr) 94 120 { 95 121 outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); … … 108 134 109 135 instance->base = base; 136 instance->indev = NULL; 137 138 /* Initialize IRQ structure. */ 139 irq_initialize(&instance->irq); 140 instance->irq.devno = device_assign_devno(); 141 instance->irq.inr = inr; 142 instance->irq.claim = s3c24xx_uart_claim; 143 instance->irq.handler = s3c24xx_uart_irq_handler; 144 instance->irq.instance = instance; 145 146 /* Disable FIFO */ 147 ioport32_t *ufcon; 148 ufcon = (ioport32_t *) (instance->base + S3C24XX_UFCON); 149 pio_write_32(ufcon, pio_read_32(ufcon) & ~0x01); 150 151 /* Set RX interrupt to pulse mode */ 152 ioport32_t *ucon; 153 ucon = (ioport32_t *) (instance->base + S3C24XX_UCON); 154 pio_write_32(ucon, pio_read_32(ucon) & ~(1 << 8)); 110 155 111 156 if (!fb_exported) { … … 124 169 } 125 170 171 void s3c24xx_uart_input_wire(s3c24xx_uart_instance_t *instance, indev_t *indev) 172 { 173 ASSERT(instance); 174 ASSERT(indev); 175 176 instance->indev = indev; 177 irq_register(&instance->irq); 178 } 179 126 180 /** @} 127 181 */
Note:
See TracChangeset
for help on using the changeset viewer.