реклама на сайте
подробности

 
 
> Портирование ядра. Написал драйвер UART как корректно его подключить., spmp8000
Sanoend
сообщение Aug 16 2012, 08:38
Сообщение #1


Участник
*

Группа: Участник
Сообщений: 20
Регистрация: 16-08-12
Пользователь №: 73 144



Здравствуйте. Я пытаюсь портировать ядро линукс на процессор SPMP8000 (основан на arm926).
Я написал свой драйвер ЮАРТ (пока сильно упрощенный вариант).
Вот код драйвера:

CODE
#include <linux/console.h>
#include <linux/serial_core.h>
#include <asm/io.h>
#include <mach/serial.h>

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/smp.h>
#include <linux/termios.h>
#include <linux/amba/bus.h>
#include <linux/amba/serial.h>
#include <linux/io.h>
#include <mach/platform.h>
#include <mach/hardware.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
#include <asm/setup.h>
#include <asm/mach/arch.h>
#include <asm/mach/flash.h>
#include <asm/mach/irq.h>
#include <asm/mach/map.h>
#include <asm/mach/time.h>




//запись символа в юарт0
static void putc(int c)
{
int timeout=4000;

if (UART0_STATUS1 & 0x1E) return;
while (timeout > 0) {
if ((UART0_STATUS2 & 0x10) && ((UART0_STATUS3 & 4) == 0)) {
UART0_DATA = c;
break;
}
timeout--;
}
}

// функция printk в ЮАРТ
static void sanoprintk(struct console *co, const char *s, u_int count){
int i;
/* Пишем каждый символ */
for (i = 0; i < count; i++, s++) {
if (*s == '\n'){
putc('\r');
}
putc(*s);
}
}


static int __init sano_console_setup(struct console *co, char *options)
{
return 0;
}


/* Заполняем структуру консоли */

static struct console sano_uart_console = {
.name = "ttyS", /* Имя консоли */
.write = sanoprintk, /* Как делать printk в консоли */
// .device = uart_console_device, /* Предоставлена ядром serial */
.setup = sano_console_setup,
.flags = CON_PRINTBUFFER, /* Флаг по умолчанию */
.index = -1, /* Инициализация в неправильное значение */
};
//register_console(&sano_uart_console);


/* Инициализация консоли */

static int __init sano_uart_console_init(void)
{
/* Регистрация этой консоли */
register_console(&sano_uart_console);
return 0;
}

console_initcall(sano_uart_console_init); /* Метка инициализации консоли */

В Makefile arch части добавил obj-y += serial.o, ядро собирается и драйвер в его добавляется, но вывод сообщений в ЮАРТ не происходит.

Однако если я в файде /init/main.c добавляю свою функцию sanoprintk , а так же заполняю и инициализирую структуру static struct console sano_uart_console прямо в начале функции start_kernel, то вывод в юарт работает так как надо.
Выглядит это примерно так
CODE
#ifdef STANDALONE_DEBUG
#define putstr printf
#else

static void sanoprintk(struct console *co, const char *s, u_int count);

#include <mach/uncompress.h>
#endif

static void sanoprintk(struct console *co, const char *s, u_int count){
int i;
/* Пишем каждый символ */
for (i = 0; i < count; i++, s++) {
if (*s == '\n'){
putc('\r');
}
putc(*s);
}
}

asmlinkage void __init start_kernel(void)
{
/* Параметры каждого из поддерживаемых портов USB_UART */
/* Заполняем структуру консоли */

static struct console sano_uart_console = {
.name = "ttyS", /* Имя консоли */
.write = sanoprintk, /* Как делать printk в консоли */
.flags = CON_PRINTBUFFER, /* Флаг по умолчанию */
.index = -1, /* Инициализация в неправильное значение */
};
register_console(&sano_uart_console);



Однако, это крайне не верное решение. Подскажите пожалуйста как подключить драйвер вынесенный в отдельный файл arch части ядра.

П.С. извиняюсь за много текста, но так и не понял как запехать тег CODE под спойлер

Сообщение отредактировал Rst7 - Aug 17 2012, 12:14
Go to the top of the page
 
+Quote Post
 
Start new topic
Ответов
Sanoend
сообщение Sep 4 2012, 08:21
Сообщение #2


Участник
*

Группа: Участник
Сообщений: 20
Регистрация: 16-08-12
Пользователь №: 73 144



Спасибо за наводку. Активность на шине посмотрю.
Расскажите пожалуйста, в общих чертах, как сделать, что бы драйвер знал о том как и куда подключен дисплей.
В данный моммент я провожу инит дисплея так
CODE

#define EPSONREGSTART 0x93000000
#define EPSONREGLEN 0x00100000
#define EPSONFBSTART 0x93200000
/* 512kB framebuffer */
#define EPSONFBLEN 512*1024


static struct s1d13xxxfb_regval s1d13xxxfb_initregs[] = {
/* line 344 of HP's doc */
{0x0000,0x04}, // Prod + Rev Code Register
{0x0001,0x00}, // Miscellaneous Register
{0x01FC,0x00}, // Display Mode Register
{0x0004,0x00}, // General IO Pins Configuration Register 0
{0x0005,0x00}, // General IO Pins Configuration Register 1
{0x0008,0x00}, // General IO Pins Control Register 0
{0x0009,0x00}, // General IO Pins Control Register 1
{0x0010,0x01}, // Memory Clock Configuration Register
{0x0014,0x11}, // LCD Pixel Clock Configuration Register
{0x0018,0x01}, // CRT/TV Pixel Clock Configuration Register
{0x001C,0x01}, // MediaPlug Clock Configuration Register
{0x001E,0x01}, // CPU To Memory Wait State Select Register
{0x0020,0x00}, // Memory Configuration Register
{0x0021,0x45}, // DRAM Refresh Rate Register
{0x002A,0x01}, // DRAM Timings Control Register 0
{0x002B,0x03}, // DRAM Timings Control Register 1
{0x0030,0x1c}, // Panel Type Register
{0x0031,0x00}, // MOD Rate Register
{0x0032,0x4F}, // LCD Horizontal Display Width Register
{0x0034,0x07}, // LCD Horizontal Non-Display Period Register
{0x0035,0x01}, // TFT FPLINE Start Position Register
{0x0036,0x0B}, // TFT FPLINE Pulse Width Register
{0x0038,0xEF}, // LCD Vertical Display Height Register 0
{0x0039,0x00}, // LCD Vertical Display Height Register 1
{0x003A,0x13}, // LCD Vertical Non-Display Period Register
{0x003B,0x0B}, // TFT FPFRAME Start Position Register
{0x003C,0x01}, // TFT FPFRAME Pulse Width Register
{0x0040,0x05}, // LCD Display Mode Register (2:4bpp,3:8bpp,5:16bpp)
{0x0041,0x00}, // LCD Miscellaneous Register
{0x0042,0x00}, // LCD Display Start Address Register 0
{0x0043,0x00}, // LCD Display Start Address Register 1
{0x0044,0x00}, // LCD Display Start Address Register 2
{0x0046,0x80}, // LCD Memory Address Offset Register 0
{0x0047,0x02}, // LCD Memory Address Offset Register 1
{0x0048,0x00}, // LCD Pixel Panning Register
{0x004A,0x00}, // LCD Display FIFO High Threshold Control Register
{0x004B,0x00}, // LCD Display FIFO Low Threshold Control Register
{0x0050,0x4F}, // CRT/TV Horizontal Display Width Register
{0x0052,0x13}, // CRT/TV Horizontal Non-Display Period Register
{0x0053,0x01}, // CRT/TV HRTC Start Position Register
{0x0054,0x0B}, // CRT/TV HRTC Pulse Width Register
{0x0056,0xDF}, // CRT/TV Vertical Display Height Register 0
{0x0057,0x01}, // CRT/TV Vertical Display Height Register 1
{0x0058,0x2B}, // CRT/TV Vertical Non-Display Period Register
{0x0059,0x09}, // CRT/TV VRTC Start Position Register
{0x005A,0x01}, // CRT/TV VRTC Pulse Width Register
{0x005B,0x10}, // TV Output Control Register
{0x0060,0x03}, // CRT/TV Display Mode Register (2:4bpp,3:8bpp,5:16bpp)
{0x0062,0x00}, // CRT/TV Display Start Address Register 0
{0x0063,0x00}, // CRT/TV Display Start Address Register 1
{0x0064,0x00}, // CRT/TV Display Start Address Register 2
{0x0066,0x40}, // CRT/TV Memory Address Offset Register 0
{0x0067,0x01}, // CRT/TV Memory Address Offset Register 1
{0x0068,0x00}, // CRT/TV Pixel Panning Register
{0x006A,0x00}, // CRT/TV Display FIFO High Threshold Control Register
{0x006B,0x00}, // CRT/TV Display FIFO Low Threshold Control Register
{0x0070,0x00}, // LCD Ink/Cursor Control Register
{0x0071,0x01}, // LCD Ink/Cursor Start Address Register
{0x0072,0x00}, // LCD Cursor X Position Register 0
{0x0073,0x00}, // LCD Cursor X Position Register 1
{0x0074,0x00}, // LCD Cursor Y Position Register 0
{0x0075,0x00}, // LCD Cursor Y Position Register 1
{0x0076,0x00}, // LCD Ink/Cursor Blue Color 0 Register
{0x0077,0x00}, // LCD Ink/Cursor Green Color 0 Register
{0x0078,0x00}, // LCD Ink/Cursor Red Color 0 Register
{0x007A,0x1F}, // LCD Ink/Cursor Blue Color 1 Register
{0x007B,0x3F}, // LCD Ink/Cursor Green Color 1 Register
{0x007C,0x1F}, // LCD Ink/Cursor Red Color 1 Register
{0x007E,0x00}, // LCD Ink/Cursor FIFO Threshold Register
{0x0080,0x00}, // CRT/TV Ink/Cursor Control Register
{0x0081,0x01}, // CRT/TV Ink/Cursor Start Address Register
{0x0082,0x00}, // CRT/TV Cursor X Position Register 0
{0x0083,0x00}, // CRT/TV Cursor X Position Register 1
{0x0084,0x00}, // CRT/TV Cursor Y Position Register 0
{0x0085,0x00}, // CRT/TV Cursor Y Position Register 1
{0x0086,0x00}, // CRT/TV Ink/Cursor Blue Color 0 Register
{0x0087,0x00}, // CRT/TV Ink/Cursor Green Color 0 Register
{0x0088,0x00}, // CRT/TV Ink/Cursor Red Color 0 Register
{0x008A,0x1F}, // CRT/TV Ink/Cursor Blue Color 1 Register
{0x008B,0x3F}, // CRT/TV Ink/Cursor Green Color 1 Register
{0x008C,0x1F}, // CRT/TV Ink/Cursor Red Color 1 Register
{0x008E,0x00}, // CRT/TV Ink/Cursor FIFO Threshold Register
{0x0100,0x00}, // BitBlt Control Register 0
{0x0101,0x00}, // BitBlt Control Register 1
{0x0102,0x00}, // BitBlt ROP Code/Color Expansion Register
{0x0103,0x00}, // BitBlt Operation Register
{0x0104,0x00}, // BitBlt Source Start Address Register 0
{0x0105,0x00}, // BitBlt Source Start Address Register 1
{0x0106,0x00}, // BitBlt Source Start Address Register 2
{0x0108,0x00}, // BitBlt Destination Start Address Register 0
{0x0109,0x00}, // BitBlt Destination Start Address Register 1
{0x010A,0x00}, // BitBlt Destination Start Address Register 2
{0x010C,0x00}, // BitBlt Memory Address Offset Register 0
{0x010D,0x00}, // BitBlt Memory Address Offset Register 1
{0x0110,0x00}, // BitBlt Width Register 0
{0x0111,0x00}, // BitBlt Width Register 1
{0x0112,0x00}, // BitBlt Height Register 0
{0x0113,0x00}, // BitBlt Height Register 1
{0x0114,0x00}, // BitBlt Background Color Register 0
{0x0115,0x00}, // BitBlt Background Color Register 1
{0x0118,0x00}, // BitBlt Foreground Color Register 0
{0x0119,0x00}, // BitBlt Foreground Color Register 1
{0x01E0,0x00}, // Look-Up Table Mode Register
{0x01E2,0x00}, // Look-Up Table Address Register
/* not sure, wouldn't like to mess with the driver */
{0x01E4,0x00}, // Look-Up Table Data Register
/* jornada doc says 0x00, but I trust the driver */
{0x01F0,0x10}, // Power Save Configuration Register
{0x01F1,0x00}, // Power Save Status Register
{0x01F4,0x00}, // CPU-to-Memory Access Watchdog Timer Register
{0x01FC,0x01}, // Display Mode Register(0x01:LCD, 0x02:CRT, 0x03:LCD&CRT)
};


static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
.initregs = s1d13xxxfb_initregs,
.initregssize = ARRAY_SIZE(s1d13xxxfb_initregs),
.platform_init_video = NULL
};

static struct resource s1d13xxxfb_resources[] = {
[0] = {
.start = EPSONFBSTART,
.end = EPSONFBSTART + EPSONFBLEN,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = EPSONREGSTART,
.end = EPSONREGSTART + EPSONREGLEN,
.flags = IORESOURCE_MEM,
}
};

static struct platform_device s1d13xxxfb_device = {
.name = S1D_DEVICENAME,
.id = 0,
.dev = {
.platform_data = &s1d13xxxfb_data,
},
.num_resources = ARRAY_SIZE(s1d13xxxfb_resources),
.resource = s1d13xxxfb_resources,
};

static struct platform_device *devices[] __initdata = {
&s1d13xxxfb_device,
};


static int __init spmp_displ_init(void)
{


int ret = -ENODEV;
ret = platform_add_devices(devices, ARRAY_SIZE(devices));
return ret;
}

arch_initcall(spmp_displ_init);




Go to the top of the page
 
+Quote Post

Сообщений в этой теме
- Sanoend   Портирование ядра. Написал драйвер UART как корректно его подключить.   Aug 16 2012, 08:38
- - IgorKossak   Цитата(Sanoend @ Aug 16 2012, 11:38) П.С....   Aug 17 2012, 11:11
- - Idle   Цитата(Sanoend @ Aug 16 2012, 12:38) Здра...   Aug 18 2012, 12:51
- - Sanoend   IgorKossak - спасибо. Буду знать и использовать. ...   Aug 21 2012, 06:58
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 10:58) Idle...   Aug 21 2012, 07:35
- - Sanoend   Я так и пробовал. К сожалению в переписке не хвата...   Aug 21 2012, 08:08
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 12:08) Напр...   Aug 21 2012, 08:16
- - Sanoend   нет linux/clkdev.h берется не из mach части а из о...   Aug 21 2012, 08:59
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 12:59) Не п...   Aug 21 2012, 09:05
- - Sanoend   есть ещё патч в2 http://lists.infradead.org/piperm...   Aug 21 2012, 09:18
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 13:18) есть...   Aug 21 2012, 09:51
- - Sanoend   Можно чуть подробнее, что такое cherry-pick ? Как...   Aug 21 2012, 10:21
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 14:21) Можн...   Aug 21 2012, 10:38
- - Sanoend   второй патч 3.2.28 Куча ошибок сборки /home/armker...   Aug 21 2012, 12:53
- - Idle   хм, а без патча собирается? он в arch/arm/kernel/s...   Aug 21 2012, 13:14
- - Sanoend   нет в suspend.c он не чего не правил. Заметил полн...   Aug 21 2012, 13:57
|- - Dron_Gus   Цитата(Sanoend @ Aug 21 2012, 17:57) CONF...   Aug 21 2012, 19:04
|- - Idle   Цитата(Sanoend @ Aug 21 2012, 17:57) Заме...   Aug 22 2012, 05:47
- - Sanoend   Idle - файлы /arch/arm/Kconfig /arch/arm/Makefile...   Aug 22 2012, 08:32
|- - Idle   Цитата(Sanoend @ Aug 22 2012, 12:32) /arc...   Aug 22 2012, 09:18
|- - Idle   Цитата(Sanoend @ Aug 22 2012, 12:32) Или ...   Aug 22 2012, 09:59
|- - Sanoend   Цитата(Idle @ Aug 22 2012, 12:59) -D__LIN...   Aug 22 2012, 10:04
|- - Idle   Цитата(Sanoend @ Aug 22 2012, 14:04) можн...   Aug 22 2012, 10:13
- - Sanoend   если поменять в конфиге CONFIG_ARCH_VERSATILE=y н...   Aug 22 2012, 09:43
- - Sanoend   Не понял ядро чего? Процессора, если так , то spmp...   Aug 22 2012, 10:43
|- - Idle   Цитата(Sanoend @ Aug 22 2012, 14:43) Не п...   Aug 22 2012, 10:50
- - Sanoend   Idle спасибо вам за помощь. Ну опубликую для истор...   Aug 22 2012, 11:44
|- - Idle   Цитата(Sanoend @ Aug 22 2012, 15:44) у ме...   Aug 22 2012, 12:22
- - Sanoend   посмотрел в ванили 3.5.х там эта функция есть. Так...   Aug 22 2012, 12:41
- - Sanoend   Ядро упорно собирается под арм версализ. Пытаюсь в...   Aug 22 2012, 14:09
- - Idle   а зачем тебе свой конфиг, выбери в дефолтном нужны...   Aug 22 2012, 16:13
- - Sanoend   Удалось собрать ядро. В данный момент запускается ...   Aug 23 2012, 05:11
- - Sanoend   Удалось запустить ядро. Прежде всего хочу поблагод...   Sep 4 2012, 06:45
- - kurtis   Я могу ошибаться, но как мне кажется, драйвер ниче...   Sep 4 2012, 08:08
- - kurtis   Я бегло глянул драйвер s1d13xxxfb.c, там походу пр...   Sep 4 2012, 09:03
|- - Idle   Цитата(kurtis @ Sep 4 2012, 13:03) Нужно ...   Sep 4 2012, 09:09
- - Sanoend   RE: Портирование ядра. Написал драйвер UART как корректно его подключить.   Sep 4 2012, 13:10
- - Sanoend   Новости и вопросы с полей. На контроллер ЛСД не по...   Sep 7 2012, 06:40


Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 8th August 2025 - 03:55
Рейтинг@Mail.ru


Страница сгенерированна за 0.01406 секунд с 7
ELECTRONIX ©2004-2016