Главная страница


ru.linux

 
 - RU.LINUX ---------------------------------------------------------------------
 From : Nickita A Startcev                   2:469/105.96   09 Jun 2005  17:57:38
 To : All
 Subject : Помогите с написанием драйвера
 -------------------------------------------------------------------------------- 
 
 
 
 Ядро 2.6.11
 Платформа iPAQ hx 2110
 Взял за основу похожий драйвер lcd, модифицировал немного.
 Все волшебные константы вытащены haret'ом из рабочего девайса под виндой.
 При выполнении modprobe hx2100_lcd имеем падение. Что я делаю неправильно?
 ======
 # modprobe hx2100_lcd
 Internal error: Oops - undefined instruction: 0 [#1]
 Modules linked in: hx2100_lcd backlight lcd
 CPU: 0
 PC is at add_preferred_console+0x2c/0xcc
 LR is at hx2100_lcd_init+0x14/0xa4 [hx2100_lcd]
 pc : [<c0012014>]    lr : [<bf005074>]    Not tainted
 sp : c0339f70  ip : c0339f88  fp : c0339f84
 r10: 00000000  r9 : c0338000  r8 : c001f904
 r7 : 00000000  r6 : c016d198  r5 : bf005620  r4 : c016d1b0
 r3 : bf005060  r2 : bf005620  r1 : 00000001  r0 : bf0055b4
 Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  Segment user
 Control: 397F  Table: A05B0000  DAC: 00000015
 Process modprobe (pid: 651, stack limit = 0xc0338194)
 Stack: (0xc0339f70 to 0xc033a000)
 9f60:                                     c016d1b0 bf005620 c0339fa4 c0339f88
 9f80: c004d064 bf00506c 000090d8 000150ec 000150e0 00000080 00000000 c0339fa8
 9fa0: c001f780 c004cec0 000090d8 c0026454 40136000 00000ba0 00015170 00000000
 9fc0: 000090d8 000150ec 000150e0 00000000 00015170 00000000 00000000 00000000
 9fe0: 000144f0 befffbf4 0000a264 400e3ddc 60000010 40136000 ae55cd8e 3ebf7cd8
 Backtrace:
 [<bf005060>] (hx2100_lcd_init+0x0/0xa4 [hx2100_lcd]) from [<c004d064>]
 (sys_init_module+0x1b0/0x318) r5 = BF005620  r4 = C016D1B0
 [<c004ceb4>] (sys_init_module+0x0/0x318) from [<c001f780>]
 (ret_fast_syscall+0x0/0x2c)
  r7 = 00000080  r6 = 000150E0  r5 = 000150EC  r4 = 000090D8
 Code: c0009000 00000040 c0012040 0000000a (ffffffff)
  Segmentation fault
 ======
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/tty.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/lcd.h>
 #include <linux/backlight.h>
 #include <linux/fb.h>
 #include <linux/err.h>
 #include <asm/arch/pxafb.h>
 
 #include <asm/mach-types.h>
 #include <asm/hardware.h>
 #include <asm/setup.h>
 
 #include <asm/mach/arch.h>
 #include <asm/arch/pxa-regs.h>
 #include <asm/arch/hx2100-gpio.h>
 #include <asm/arch/ipaq.h>
 
 #include "../../common/ipaq/asic3_base.h"
 /*
   On screen enable, we get
 
      h3800_lcd_power_on(1)
      LCD controller starts
      h3800_lcd_enable(1)
 
   On screen disable, we get
 
      h3800_lcd_enable(0)
      LCD controller stops
      h3800_lcd_power_on(0)
 */
 
 static int hx2100_lcd_set_power( struct lcd_device *lm, int level )
 {
 #if 0
         if ( level > 0 ) {
                 /* Usually, ON, NV_ON, 9V_ON, 5V_ON... */
                 GPSR(50) = GPIO_bit(50);        /* 2.5V to LCD - DVDD_EN */
                 GPSR(GPIO_NR_HX2100_LCD_SOMETHING) =
 GPIO_bit(GPIO_NR_hx2100_LCD_SOMETHING);
                 mdelay(30);
                 GPSR(48) = GPIO_bit(48);        /* -7V to LCD  - VGL_EN */
                 mdelay(50);
         } else {
                 mdelay(5);
                 GPCR(50) = GPIO_bit(50);
                 mdelay(50);
                 GPCR(48) = GPIO_bit(48);
                 mdelay(100);
                 GPCR(GPIO_NR_hx2100_LCD_SOMETHING) =
 GPIO_bit(GPIO_NR_hx2100_LCD_SOMETHING);
         }
 #endif
         return 0;
 }
 
 static int hx2100_lcd_get_power( struct lcd_device *lm )
 {
 #if 0
         if (GPLR(GPIO_NR_hx2100_LCD_SOMETHING) &
 GPIO_bit(GPIO_NR_hx2100_LCD_SOMETHING))
                 return 4;
         else
 #endif
                 return 0;
 }
 
 static int hx2100_backlight_set_power (struct backlight_device *bl, int level)
 {
         /*
          * GPIO16: LCD_PWM: control brightness of frontlight via pulse width
 modulation
          * GPIO36: Frontlight power enable (I suggest not enabling without
 running pwm
          */
 #if 0
         if (level > 0) {
                 GPDR(16) |= GPIO_bit(16);
                 GPDR(36) |= GPIO_bit(36);
                 GPCR(36)  = GPIO_bit(36);
                 GPSR(16)  = GPIO_bit(16);
                 GPSR(36)  = GPIO_bit(36);
         } else {
                 GPCR(36) = GPIO_bit(36);
                 GPCR(16) = GPIO_bit(16);
         }
 #endif
         return 0;
 }
 
 static int hx2100_backlight_get_power (struct backlight_device *bl)
 {
         if (GPLR(36) & GPIO_bit(36))
                 return 4;
         else
                 return 0;
 }
 
 static struct pxafb_mach_info hx2100_fb_info = {
         .pixclock =     0,      /* clock period in ps */
         .bpp =          16,
         .xres =         240,
         .yres =         320,
         .hsync_len =    5,
         .vsync_len =    13,
         .left_margin =  27,
         .upper_margin = 1,
         .right_margin = 11,
         .lower_margin = 49,
         .sync =         0, /* both horiz and vert active low sync */
         .lccr0 =        0x7b008f9,
         .lccr3 =        0x4700023
 };
 
 static struct lcd_properties hx2100_lcd_properties = {
         .owner         = THIS_MODULE,
         .set_power     = hx2100_lcd_set_power,
         .get_power     = hx2100_lcd_get_power,
 };
 
 static struct backlight_properties hx2100_backlight_properties = {
         .owner         = THIS_MODULE,
         .set_power     = hx2100_backlight_set_power,
         .get_power     = hx2100_backlight_get_power,
 };
 
 static struct lcd_device *pxafb_lcd_device;
 static struct backlight_device *pxafb_backlight_device;
 
 static int
 hx2100_lcd_init (void)
 {
         if (!machine_is_HP_iPAQ_hx2100 ())
             return -741;
 
         set_pxa_fb_info(&hx2100_fb_info); //??
 
         pxafb_lcd_device = lcd_device_register("pxafb", (void*)&hx2100_fb_info,
                 &hx2100_lcd_properties);
         if (IS_ERR (pxafb_lcd_device))
                 return PTR_ERR (pxafb_lcd_device);
 
         pxafb_backlight_device = backlight_device_register("pxafb", NULL,
                 &hx2100_backlight_properties);
         if (IS_ERR (pxafb_backlight_device)) {
                 lcd_device_unregister (pxafb_lcd_device);
                 return PTR_ERR (pxafb_backlight_device);
         }
 
         return 0;
 }
 
 static void
 hx2100_lcd_exit (void)
 {
         lcd_device_unregister(pxafb_lcd_device);
         backlight_device_unregister(pxafb_backlight_device);
 }
 
 module_init (hx2100_lcd_init);
 module_exit (hx2100_lcd_exit);
 
 MODULE_AUTHOR("Nickita Startcev <nicka@cobra.ru>");
 MODULE_DESCRIPTION("LCD driver for ipaq hx2100");
 MODULE_LICENSE("GPL");
 
 ======
 
 .                                                С уважением, Hикита.
 ... bed command or file name
 --- GoldED+/W32 1.1.5-030428
  * Origin:  (2:469/105.96)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Помогите с написанием драйвера   Nickita A Startcev   09 Jun 2005 17:57:38 
Архивное /ru.linux/341942a84b9f.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional