Changeset 277cf60 in mainline


Ignore:
Timestamp:
2010-07-25T16:52:18Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b8b4efa
Parents:
ec08286
Message:

Use I/O structure to access S3C24xx UART registers.

Location:
kernel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/mach/gta02/gta02.c

    rec08286 r277cf60  
    7575static void gta02_timer_irq_handler(irq_t *irq);
    7676
    77 static void *gta02_scons_out;
    7877static outdev_t *gta02_scons_dev;
    7978static s3c24xx_irqc_t gta02_irqc;
     
    9796        s3c24xx_irqc_regs_t *irqc_regs;
    9897
    99         gta02_scons_out = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);
    10098        gta02_timer = (void *) hw_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE);
    10199        irqc_regs = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE);
     
    176174
    177175        /* Initialize serial port of the debugging console. */
    178         gta02_scons_dev = s3c24xx_uart_init((ioport8_t *) gta02_scons_out,
    179                 S3C24XX_INT_UART2);
     176        s3c24xx_uart_io_t *scons_io;
     177
     178        scons_io = (void *) hw_map(GTA02_SCONS_BASE, PAGE_SIZE);
     179        gta02_scons_dev = s3c24xx_uart_init(scons_io, S3C24XX_INT_UART2);
     180
    180181        if (gta02_scons_dev) {
    181 
    182182                /* Create output device. */
    183183                stdout_wire(gta02_scons_dev);
     
    187187static void gta02_input_init(void)
    188188{
    189         s3c24xx_uart_instance_t *scons_inst;
     189        s3c24xx_uart_t *scons_inst;
    190190
    191191        if (gta02_scons_dev) {
  • kernel/genarch/include/drivers/s3c24xx_uart/s3c24xx_uart.h

    rec08286 r277cf60  
    4242#include <typedefs.h>
    4343
     44/** S3C24xx UART I/O */
    4445typedef struct {
    45         ioport8_t *base;
     46        uint32_t ulcon;
     47        uint32_t ucon;
     48        uint32_t ufcon;
     49        uint32_t umcon;
     50
     51        uint32_t utrstat;
     52        uint32_t uerstat;
     53        uint32_t ufstat;
     54        uint32_t umstat;
     55
     56        uint32_t utxh;
     57        uint32_t urxh;
     58
     59        uint32_t ubrdiv;
     60} s3c24xx_uart_io_t;
     61
     62/** S3C24xx UART instance */
     63typedef struct {
     64        s3c24xx_uart_io_t *io;
    4665        indev_t *indev;
    4766        irq_t irq;
    48 } s3c24xx_uart_instance_t;
     67} s3c24xx_uart_t;
    4968
    50 extern outdev_t *s3c24xx_uart_init(ioport8_t *, inr_t inr);
    51 extern void s3c24xx_uart_input_wire(s3c24xx_uart_instance_t *,
     69extern outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *, inr_t inr);
     70extern void s3c24xx_uart_input_wire(s3c24xx_uart_t *,
    5271    indev_t *);
    5372
  • kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c

    rec08286 r277cf60  
    4747#include <str.h>
    4848
    49 /** S3C24xx UART register offsets */
    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
    61 
    6249/* Bits in UTRSTAT register */
    6350#define S3C24XX_UTRSTAT_TX_EMPTY        0x4
     
    6653static void s3c24xx_uart_sendb(outdev_t *dev, uint8_t byte)
    6754{
    68         s3c24xx_uart_instance_t *instance =
    69             (s3c24xx_uart_instance_t *) dev->data;
    70         ioport32_t *utrstat, *utxh;
    71 
    72         utrstat = (ioport32_t *) (instance->base + S3C24XX_UTRSTAT);
    73         utxh = (ioport32_t *) (instance->base + S3C24XX_UTXH);
     55        s3c24xx_uart_t *uart =
     56            (s3c24xx_uart_t *) dev->data;
    7457
    7558        /* Wait for transmitter to be empty. */
    76         while ((pio_read_32(utrstat) & S3C24XX_UTRSTAT_TX_EMPTY) == 0)
     59        while ((pio_read_32(&uart->io->utrstat) & S3C24XX_UTRSTAT_TX_EMPTY) == 0)
    7760                ;
    7861
    79         pio_write_32(utxh, byte);
     62        pio_write_32(&uart->io->utxh, byte);
    8063}
    8164
     
    10083static void s3c24xx_uart_irq_handler(irq_t *irq)
    10184{
    102         s3c24xx_uart_instance_t *instance = irq->instance;
    103         ioport32_t *utrstat, *urxh;
     85        s3c24xx_uart_t *uart = irq->instance;
    10486
    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);
     87        if ((pio_read_32(&uart->io->utrstat) & S3C24XX_UTRSTAT_RDATA) != 0) {
     88                uint32_t data = pio_read_32(&uart->io->urxh);
     89                indev_push_character(uart->indev, data & 0xff);
    11190        }
    11291}
     
    11796};
    11897
    119 outdev_t *s3c24xx_uart_init(ioport8_t *base, inr_t inr)
     98outdev_t *s3c24xx_uart_init(s3c24xx_uart_io_t *io, inr_t inr)
    12099{
    121100        outdev_t *uart_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC);
     
    123102                return NULL;
    124103
    125         s3c24xx_uart_instance_t *instance =
    126             malloc(sizeof(s3c24xx_uart_instance_t), FRAME_ATOMIC);
    127         if (!instance) {
     104        s3c24xx_uart_t *uart =
     105            malloc(sizeof(s3c24xx_uart_t), FRAME_ATOMIC);
     106        if (!uart) {
    128107                free(uart_dev);
    129108                return NULL;
     
    131110
    132111        outdev_initialize("s3c24xx_uart_dev", uart_dev, &s3c24xx_uart_ops);
    133         uart_dev->data = instance;
     112        uart_dev->data = uart;
    134113
    135         instance->base = base;
    136         instance->indev = NULL;
     114        uart->io = io;
     115        uart->indev = NULL;
    137116
    138117        /* 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;
     118        irq_initialize(&uart->irq);
     119        uart->irq.devno = device_assign_devno();
     120        uart->irq.inr = inr;
     121        uart->irq.claim = s3c24xx_uart_claim;
     122        uart->irq.handler = s3c24xx_uart_irq_handler;
     123        uart->irq.instance = uart;
    145124
    146125        /* Disable FIFO */
    147         ioport32_t *ufcon;
    148         ufcon = (ioport32_t *) (instance->base + S3C24XX_UFCON);
    149         pio_write_32(ufcon, pio_read_32(ufcon) & ~0x01);
     126        pio_write_32(&uart->io->ufcon,
     127            pio_read_32(&uart->io->ufcon) & ~0x01);
    150128
    151129        /* 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));
     130        pio_write_32(&uart->io->ucon,
     131            pio_read_32(&uart->io->ucon) & ~(1 << 8));
    155132
    156133        if (!fb_exported) {
     
    161138                sysinfo_set_item_val("fb", NULL, true);
    162139                sysinfo_set_item_val("fb.kind", NULL, 3);
    163                 sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(base));
     140                sysinfo_set_item_val("fb.address.physical", NULL, KA2PA(io));
    164141
    165142                fb_exported = true;
     
    169146}
    170147
    171 void s3c24xx_uart_input_wire(s3c24xx_uart_instance_t *instance, indev_t *indev)
     148void s3c24xx_uart_input_wire(s3c24xx_uart_t *uart, indev_t *indev)
    172149{
    173         ASSERT(instance);
     150        ASSERT(uart);
    174151        ASSERT(indev);
    175152
    176         instance->indev = indev;
    177         irq_register(&instance->irq);
     153        uart->indev = indev;
     154        irq_register(&uart->irq);
    178155}
    179156
  • kernel/generic/src/main/kinit.c

    rec08286 r277cf60  
    226226         * Run user tasks.
    227227         */
    228         for (i = 0; i < init.cnt; i++) {
     228/*      for (i = 0; i < init.cnt; i++) {
    229229                if (programs[i].task != NULL)
    230230                        program_ready(&programs[i]);
    231         }
     231        }*/
    232232       
    233233#ifdef CONFIG_KCONSOLE
Note: See TracChangeset for help on using the changeset viewer.