Changeset ec08286 in mainline for kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c
- Timestamp:
- 2010-07-25T14:35:05Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 277cf60
- Parents:
- 24697c3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.