#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define wmt_spi_lcd_err(fmt, args...) printk("[%s-%d] %s: " fmt, __FILE__,__LINE__,__FUNCTION__, ## args) #define wmt_spi_lcd_printk(fmt, ...) wmt_spi_lcd_err(fmt, ##__VA_ARGS__) #define WMT_SPI_READ_BUF_MAX_LEN 200 #define WMT_SPI_LCD_SPI_MODE SPI_MODE_0 #define WMT_SPI_LCD_A0_PIN WMT_PIN_GP1_GPIO10 #define WMT_LCD_POWER_PIN WMT_PIN_GP0_GPIO0 #define WMT_WIFI_POWER_PIN WMT_PIN_GP1_GPIO14 #define WMT_AIT_POWER_PIN WMT_PIN_GP1_GPIO12 #define WMT_PRINT_POWER_PIN WMT_PIN_GP62_WAKEUP4 #define WMT_OTG_PRINT_SWITCH_PIN WMT_PIN_GP21_HDMIDCSDA #if 0 typedef enum{ WMT_SPI_LCD_STATE_NULL, WMT_SPI_LCD_STATE_HAPPY, WMT_SPI_LCD_STATE_SUN, WMT_SPI_LCD_STATE_CLOUDY, WMT_SPI_LCD_STATE_SAD, WMT_SPI_LCD_STATE_PRINT, WMT_SPI_LCD_STATE_MESSAGE, WMT_SPI_LCD_STATE_MAX }wmt_sub_lcd_state; #endif #define WMT_SPI_LCD_IOCTL_MAGIC 0x11 #define WMT_SPI_LCD_STATE_HAPPY _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 0, int) #define WMT_SPI_LCD_STATE_SUN _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 1, int) #define WMT_SPI_LCD_STATE_CLOUDY _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 2, int) #define WMT_SPI_LCD_STATE_SAD _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 3, int) #define WMT_SPI_LCD_STATE_PRINT _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 4, int) #define WMT_SPI_LCD_STATE_MESSAGE _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 5, int) #define WMT_WIFI_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 20, int) #define WMT_AIT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 21, int) #define WMT_PRINT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 22, int) #define WMT_SWITCH_OTG_PRINT _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 23, int) #define WMT_GET_LCD_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 30, int) #define WMT_GET_WIFI_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 31, int) #define WMT_GET_AIT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 32, int) #define WMT_GET_PRINT_POWER _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 33, int) #define WMT_GET_OTG_PRINT_STATE _IOW(WMT_SPI_LCD_IOCTL_MAGIC, 34, int) static int wmt_sub_lcd_display_state=WMT_SPI_LCD_STATE_HAPPY; struct wmt_spi_lcd_dev { wait_queue_head_t read_wq; struct mutex read_mutex; struct spi_device *spi; struct miscdevice sub_lcd_misc_device; struct kobject *kobj; bool irq_enabled; spinlock_t irq_enabled_lock; int lcd_val; int wifi_val; int ait_val; int print_val; int otg_print_state; }; struct wmt_spi_lcd_dev *wmt_spi_lcd_pContext; const char wmt_spi_lcd_display_happy[][64]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0, 0xF0,0xF0,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x3E,0x3E,0x3E,0x3E,0x1E,0x1F,0x1F,0x1F, 0x1F,0x1F,0x1F,0x1E,0x3E,0x3E,0x3E,0x3E,0x7E,0x7C,0x7C,0xFC,0xF8,0xF8,0xF0,0xF0, 0xE0,0xC0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x0F,0x07, 0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03, 0x07,0x0F,0x0F,0x1F,0x3F,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0x80,0xF0,0xFC,0xFF,0xFF,0xFF,0x1F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0xC0,0xF0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF0,0xE0, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x1F,0x7F,0xFF,0xFF,0xFC,0xF0,0x80,0x00, 0xF0,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x0F,0x01,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x0F, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0xF8, 0x0F,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0x3F, 0x00,0x01,0x0F,0x3F,0xFF,0xFF,0xFE,0xF8,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x07,0x0F,0x3F,0x7F,0x7F,0xFC,0xF8,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0, 0xE0,0xE0,0xE0,0xF0,0xF0,0xF8,0xFC,0x7F,0x7F,0x3F,0x0F,0x07,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xFE,0xFF,0xFF,0x7F,0x1F,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x3F,0x7F,0xFF,0xFC,0xF8,0xF0,0xE0,0xC0, 0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0, 0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x07,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x07, 0x0F,0x1F,0x1F,0x3F,0x3E,0x3E,0x7E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8, 0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x7C,0x3E,0x3E,0x3F,0x1F,0x1F,0x0F, 0x0F,0x07,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; char wmt_spi_lcd_display_sad[][64]={ /* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\sad.bmp 64x64 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xE0,0xE0, 0xF0,0xF0,0xF8,0xF8,0x7C,0x7C,0x7E,0x3E,0x3E,0x3E,0x1E,0x1F,0x1F,0x1F,0x1F,0x1F, 0x1F,0x1F,0x1F,0x1F,0x1F,0x1E,0x3E,0x3E,0x3E,0x7E,0x7C,0x7C,0xF8,0xF8,0xF0,0xF0, 0xE0,0xE0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xF0,0xFC,0xFE,0xFF,0x3F,0x1F,0x0F,0x07,0x07, 0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03, 0x07,0x07,0x0F,0x1F,0x3F,0xFF,0xFE,0xFC,0xF0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00, 0x00,0xC0,0xF0,0xFC,0xFF,0xFF,0x7F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00, 0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xE0,0xF0,0xF8,0xF8,0xFC,0xFC,0xFC,0xF8,0xF8,0xF0,0xE0, 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x7F,0xFF,0xFF,0xFC,0xF0,0xC0,0x00, 0xF8,0xFF,0xFF,0xFF,0xFF,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x07,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x07,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xFF,0xFF,0xFF,0xFF,0xF8, 0x1F,0xFF,0xFF,0xFF,0xFF,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xC0,0xE0,0xE0,0xE0,0xE0, 0xE0,0xE0,0xC0,0xC0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFF,0x1F, 0x00,0x03,0x0F,0x3F,0xFF,0xFF,0xFE,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x40,0xF0,0xFC,0xFE,0xFF,0x7F,0x1F,0x0F,0x07,0x07,0x03,0x03,0x03,0x03, 0x03,0x03,0x07,0x07,0x0F,0x1F,0x3F,0xFF,0xFE,0xFC,0xF8,0x60,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xFE,0xFF,0xFF,0x3F,0x0F,0x03,0x00, 0x00,0x00,0x00,0x00,0x00,0x03,0x07,0x0F,0x3F,0x7F,0xFE,0xFC,0xF8,0xF0,0xE0,0xC0, 0xC0,0x80,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x80,0xC0, 0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7F,0x3F,0x1F,0x07,0x03,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0x07, 0x0F,0x1F,0x1F,0x1F,0x3E,0x3E,0x7E,0x7C,0x7C,0x7C,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8, 0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0x7C,0x7C,0x7C,0x7E,0x3E,0x3E,0x1F,0x1F,0x1F,0x0F, 0x07,0x07,0x03,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; char wmt_spi_lcd_display_print[][64]={ /* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\print.bmp 64x64 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,0xFF,0xFF,0xFF,0x1F, 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F, 0x1F,0x1F,0x1F,0x1F,0x1F,0xFF,0xFF,0xFF,0x1E,0x3C,0x78,0xF0,0xF0,0xE0,0xC0,0x80, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xE0,0xE0,0xE0,0xE0,0xE1,0xE3,0xE7,0xEF, 0xFF,0xFE,0xFC,0xF8,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xF0,0xFC,0xFE,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFE,0xFC,0xF8, 0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x03,0x03,0x03,0x03,0x03,0x83,0x83,0x83,0x83,0x83, 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83, 0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83,0x83, 0x83,0x83,0x83,0x83,0x83,0x03,0x03,0x03,0x03,0x03,0x03,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0x0F, 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F, 0x0F,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF, 0x01,0x07,0x0F,0x1F,0x1F,0x3F,0x3F,0x3F,0x3F,0x3F,0xBF,0xFF,0xFF,0xFF,0xFF,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0xFF,0xFF,0xFF,0xFF,0xBF,0x3F,0x3F,0x3F,0x3F,0x3F,0x1F,0x1F,0x0F,0x07,0x03, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xF0, 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0, 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0, 0xF0,0xFF,0xFF,0xFF,0xFF,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; char wmt_spi_lcd_display_message[][64]={ /* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\message.bmp 64x64 */ 0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00, 0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xBF,0x3F, 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, 0x3F,0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFC, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x7F,0xFF,0xFF, 0xFE,0xFC,0xFC,0xF8,0xF0,0xF0,0xE0,0xC0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xC0,0xE0,0xF0,0xF8,0xF8,0xFC,0xFE,0xFF, 0xFF,0x7F,0x3F,0x3F,0x1F,0x0F,0x07,0x07,0x03,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x01,0x03,0x03,0x07,0x0F,0x1F,0x1F,0x3F,0x7F,0x7F,0xFF,0xFE,0xFC,0xFC,0xF8,0xF0, 0xF8,0xF8,0xFC,0xFE,0xFF,0xFF,0x7F,0x3F,0x3F,0x1F,0x0F,0x07,0x07,0x03,0x01,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x07,0x07, 0x07,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0x3F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC, 0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x3F, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; const char wmt_spi_lcd_display_sun[][64]={ /* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\sun.bmp 64x64 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0, 0xF0,0xF0,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC,0xFE,0xFF, 0xFF,0xFE,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF0,0xF0, 0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x03,0x0F,0x3F,0x7F,0x7F,0x7E,0x78,0x00,0x00,0x00,0x00,0x80,0x80,0x87,0x8F,0x8F, 0x8F,0x8F,0x87,0x80,0x80,0x00,0x00,0x00,0x30,0x7C,0x7F,0x7F,0x7F,0x3F,0x0F,0x03, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x07,0x0F,0x0F,0x1F,0x1F,0x3F,0x7E,0x7E,0x7C,0x7C,0x78,0x00, 0x00,0xC0,0xE0,0xF0,0xF8,0xFC,0xFE,0x7E,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x0F,0x0F, 0x0F,0x0F,0x0F,0x0F,0x1F,0x1F,0x3F,0x7F,0x7E,0xFC,0xFC,0xF8,0xF0,0xE0,0x80,0x00, 0x30,0x78,0x7C,0x7C,0x7E,0x3F,0x3F,0x1F,0x1F,0x0F,0x0F,0x07,0x00,0x00,0x00,0x00, 0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0xF8, 0xFF,0xFF,0xFF,0xFF,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x1F,0xFF,0xFF,0xFF,0xFE, 0xF8,0x00,0x00,0x80,0xC0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xC0,0x80, 0x01,0x03,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x00,0x00,0x00,0x1F, 0xFF,0xFF,0xFF,0xFF,0xF0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF8,0xFF,0xFF,0xFF,0x7F, 0x1F,0x00,0x00,0x01,0x03,0x03,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x03,0x03,0x01, 0x00,0x00,0x00,0x00,0xE0,0xF0,0xF0,0xF8,0xFC,0xFC,0x7E,0x7E,0x3F,0x3F,0x1E,0x00, 0x00,0x01,0x07,0x0F,0x1F,0x3F,0x3F,0x7E,0x7E,0xFC,0xF8,0xF8,0xF0,0xF0,0xF0,0xF0, 0xF0,0xF0,0xF0,0xF8,0xF8,0xF8,0xFC,0x7E,0x7F,0x3F,0x1F,0x1F,0x0F,0x03,0x01,0x00, 0x0C,0x1E,0x3F,0x3F,0x7E,0x7E,0xFC,0xF8,0xF8,0xF0,0xF0,0xE0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80, 0xE0,0xF0,0xFC,0xFE,0xFF,0x7F,0x1E,0x00,0x00,0x00,0x00,0x01,0x01,0xE1,0xF1,0xF9, 0xF9,0xF1,0xE1,0x01,0x01,0x00,0x00,0x00,0x0C,0x3E,0x7F,0xFF,0xFE,0xFC,0xF0,0xC0, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07, 0x0F,0x0F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x7F,0xFF, 0xFF,0x7F,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x0F,0x0F, 0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; const char wmt_spi_lcd_display_cloudy[][64]={ /* ͼÏñ C:\Users\admin\Desktop\androd camera\yuhao\cloudy.bmp 64x64 */ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xE0,0xE0,0xE0,0xC0,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x87,0x8F,0x87,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xE0,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0x80,0x80,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC1,0xC1,0x81,0x80,0x80,0x18,0x38, 0x3C,0x1E,0x1E,0x0F,0x0F,0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x1E,0x3E, 0x7C,0xF8,0xF0,0xE0,0xC0,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xC0,0xF0,0xF8,0x7C,0x3C,0x1E,0x0F,0x0F, 0x07,0x07,0x03,0x03,0x03,0x03,0x01,0x01,0x03,0x03,0x03,0x03,0x07,0x07,0x0F,0x0F, 0x1E,0x3C,0x7C,0xF8,0xF0,0xC0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x03,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x20,0x70,0x70,0x70,0x70,0x20, 0x00,0x00,0x00,0x80,0xC0,0xE0,0xFC,0xFF,0xFF,0x0F,0x01,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x01,0x0F,0x1F,0x1F,0x0E,0x0F,0x0F,0x07,0x07,0x0F,0x0F,0x0F,0x1E, 0x1E,0x3C,0x78,0xF9,0xF3,0xC7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xF8,0xFE,0xFF,0x1F,0x07,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x81,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x03,0x0F,0x1F,0x3F,0x7C,0xF0,0xF0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0, 0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0, 0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xE0,0xF0, 0xF0,0x78,0x3E,0x3F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; extern int wmt_getsyspara(char *varname, unsigned char *varval, int *varlen); void wmt_spi_lcd_write_n_data(const char *wbuf,int wbuf_len) { if(wbuf_len>=WMT_SPI_READ_BUF_MAX_LEN) { wmt_spi_lcd_err("error!!"); return; } gpio_direction_output(WMT_SPI_LCD_A0_PIN,1); spi_write_then_read(wmt_spi_lcd_pContext->spi, wbuf, wbuf_len, NULL, 0); } void wmt_spi_lcd_write_data(unsigned char c) { wmt_spi_lcd_write_n_data(&c,1); } //------------------------------------------------------------------------------- //×Ó³ÌÐòÃû³Æ:lcdwc(unsigned char c). //¹¦ÄÜ:ÏòÒº¾§ÏÔʾ¿ØÖÆÆ÷ËÍÖ¸Áî. //------------------------------------------------------------------------------- void wmt_spi_lcd_write_command(unsigned char c) { gpio_direction_output(WMT_SPI_LCD_A0_PIN,0); spi_write_then_read(wmt_spi_lcd_pContext->spi, &c, 1, NULL, 0); } void wmt_spi_lcd_reset(void) //Òº¾§ÏÔʾ¿ØÖÆÆ÷³õʼ»¯×Ó³ÌÐò { #if 0 gpio_direction_output(WMT_SPI_LCD_RESET_PIN,0); mdelay(200); gpio_direction_output(WMT_SPI_LCD_RESET_PIN,1); mdelay(200); #endif wmt_spi_lcd_write_command(0xe2); mdelay(100); wmt_spi_lcd_write_command(0x2c);/////set booster on wmt_spi_lcd_write_command(0x2e); ////voltage regulator circuit on wmt_spi_lcd_write_command(0x2f);//// voltage follower circuit on wmt_spi_lcd_write_command(0xa0);// wmt_spi_lcd_write_command(0xa6);// mdelay(3); wmt_spi_lcd_write_command(0xc8);// mdelay(3); wmt_spi_lcd_write_command(0xa2);// mdelay(3); wmt_spi_lcd_write_command(0xf8); //set booster ratio mdelay(2); wmt_spi_lcd_write_command(0x00); //set X2 X3 X4 mdelay(2); wmt_spi_lcd_write_command(0x24); mdelay(2); wmt_spi_lcd_write_command(0x81); mdelay(2); wmt_spi_lcd_write_command(0x28); mdelay(2); wmt_spi_lcd_write_command(0xac); mdelay(2); wmt_spi_lcd_write_command(0x00); mdelay(2); wmt_spi_lcd_write_command(0xaf); wmt_spi_lcd_write_command(0xA4); mdelay(2); } void wmt_spi_lcd_display_picture(const char *picture) { int page,k; int skip=0; for(page=0xB0;page<0xB8;page++) { wmt_spi_lcd_write_command(page); wmt_spi_lcd_write_command(0x10); wmt_spi_lcd_write_command(0x00); for(k=0;k<8;k++) wmt_spi_lcd_write_n_data(picture+skip+k*8,8); skip+=64; } } void wmt_spi_lcd_display_state_picture(void) { switch(wmt_sub_lcd_display_state){ case WMT_SPI_LCD_STATE_HAPPY: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_happy[0]); break; case WMT_SPI_LCD_STATE_SUN: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_sun[0]); break; case WMT_SPI_LCD_STATE_CLOUDY: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_cloudy[0]); break; case WMT_SPI_LCD_STATE_SAD: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_sad[0]); break; case WMT_SPI_LCD_STATE_PRINT: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_print[0]); break; case WMT_SPI_LCD_STATE_MESSAGE: wmt_spi_lcd_display_picture(wmt_spi_lcd_display_message[0]); break; default: wmt_spi_lcd_printk("%s default wmt_sub_lcd_display_state=%d\n", __func__,wmt_sub_lcd_display_state); } } static int wmt_spi_lcd_open(struct inode *inode, struct file *filp) { struct wmt_spi_lcd_dev *spi_dev = container_of(filp->private_data, struct wmt_spi_lcd_dev, sub_lcd_misc_device); filp->private_data = spi_dev; wmt_spi_lcd_display_state_picture(); // mdelay(3000); return 0; } static long wmt_spi_lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int interval, val; struct wmt_spi_lcd_dev *spi_dev = file->private_data; wmt_sub_lcd_display_state = cmd; wmt_spi_lcd_display_state_picture(); switch(cmd){ case WMT_WIFI_POWER: if(copy_from_user(&val, argp, sizeof(val))) return -EFAULT; if(val > 1) return -EINVAL; if(val) { gpio_direction_output(WMT_WIFI_POWER_PIN,1); } else { gpio_direction_output(WMT_WIFI_POWER_PIN,0); } wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_WIFI_POWER_PIN val=%d\n",val); break; case WMT_AIT_POWER: if(copy_from_user(&val, argp, sizeof(val))) return -EFAULT; if(val > 1) return -EINVAL; if(val) { gpio_direction_output(WMT_AIT_POWER_PIN,1); } else { gpio_direction_output(WMT_AIT_POWER_PIN,0); } wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_AIT_POWER_PIN val=%d\n",val); break; case WMT_PRINT_POWER: if(copy_from_user(&val, argp, sizeof(val))) return -EFAULT; if(val > 1) return -EINVAL; if(val) { gpio_direction_output(WMT_PRINT_POWER_PIN,1); } else { gpio_direction_output(WMT_PRINT_POWER_PIN,0); } wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_PRINT_POWER_PIN val=%d\n",val); break; case WMT_SWITCH_OTG_PRINT: if(copy_from_user(&val, argp, sizeof(val))) return -EFAULT; if(val > 1) return -EINVAL; if(val) { gpio_direction_output(WMT_OTG_PRINT_SWITCH_PIN,1); } else { gpio_direction_output(WMT_OTG_PRINT_SWITCH_PIN,0); } wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN val=%d\n",val); break; case WMT_GET_LCD_POWER: spi_dev->lcd_val = wmt_gpio_getpull(WMT_LCD_POWER_PIN); wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_LCD_POWER=%d\n", spi_dev->lcd_val); interval = spi_dev->lcd_val; if(copy_to_user(argp, &interval, sizeof(interval))) { wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_LCD_POWER fail\n"); return -EFAULT; } break; case WMT_GET_WIFI_POWER: spi_dev->wifi_val = wmt_gpio_getpull(WMT_WIFI_POWER_PIN); wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_WIFI_POWER=%d\n", spi_dev->wifi_val); interval = spi_dev->wifi_val; if(copy_to_user(argp, &interval, sizeof(interval))) { wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_WIFI_POWER fail\n"); return -EFAULT; } break; case WMT_GET_AIT_POWER: spi_dev->ait_val = wmt_gpio_getpull(WMT_AIT_POWER_PIN); wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_AIT_POWER=%d\n", spi_dev->ait_val); interval = spi_dev->ait_val; if(copy_to_user(argp, &interval, sizeof(interval))) { wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_AIT_POWER fail\n"); return -EFAULT; } break; case WMT_GET_PRINT_POWER: spi_dev->print_val = wmt_gpio_getpull(WMT_PRINT_POWER_PIN); wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_PRINT_POWER=%d\n", spi_dev->print_val); interval = spi_dev->print_val; if(copy_to_user(argp, &interval, sizeof(interval))) { wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_GET_PRINT_POWER fail\n"); return -EFAULT; } break; case WMT_GET_OTG_PRINT_STATE: spi_dev->otg_print_state = wmt_gpio_getpull(WMT_OTG_PRINT_SWITCH_PIN); wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN=%d\n", spi_dev->otg_print_state); interval = spi_dev->otg_print_state; if(copy_to_user(argp, &interval, sizeof(interval))) { wmt_spi_lcd_printk("wmt_spi_lcd_ioctl WMT_OTG_PRINT_SWITCH_PIN fail\n"); return -EFAULT; } break; default: return -EINVAL; } return 0; } static const struct file_operations wmt_spi_lcd_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .open = wmt_spi_lcd_open, .unlocked_ioctl = wmt_spi_lcd_ioctl, }; static ssize_t wmt_spi_lcd_cat_dbg(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", wmt_sub_lcd_display_state); } static ssize_t wmt_spi_lcd_echo_dbg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { sscanf(buf,"%d", &wmt_sub_lcd_display_state); wmt_sub_lcd_display_state += WMT_SPI_LCD_STATE_HAPPY; wmt_spi_lcd_display_state_picture(); return count; } static DEVICE_ATTR(dbg, S_IRUGO | S_IWUSR, wmt_spi_lcd_cat_dbg, wmt_spi_lcd_echo_dbg); static struct attribute *sub_lcd_attributes[] = { &dev_attr_dbg.attr, NULL }; static const struct attribute_group wmt_spi_lcd_group = { .attrs = sub_lcd_attributes, }; static int wmt_spi_lcd_sysfs_create_group(struct wmt_spi_lcd_dev *spi_dev, const struct attribute_group *group) { int err; spi_dev->kobj = kobject_create_and_add("wmt_spi_lcd", NULL) ; if(!spi_dev->kobj){ wmt_spi_lcd_printk("kobj create failed.\n"); return -ENOMEM; } /* Register sysfs hooks */ err = sysfs_create_group(spi_dev->kobj, group); if (err < 0){ kobject_del(spi_dev->kobj); wmt_spi_lcd_printk("Create sysfs group failed!\n"); return -ENOMEM; } return 0; } static void wmt_spi_lcd_sysfs_remove_group(struct wmt_spi_lcd_dev *spi_dev, const struct attribute_group *group) { sysfs_remove_group(spi_dev->kobj, group); kobject_del(spi_dev->kobj); return; } static int wmt_spi_lcd_probe(struct spi_device *spi) { struct wmt_spi_lcd_dev *spi_dev = NULL; int ret = 0; ret = gpio_request(WMT_SPI_LCD_A0_PIN, "sub_lcd_control"); if (ret) goto err_exit; spi_dev = kzalloc(sizeof(*spi_dev), GFP_KERNEL); if (spi_dev == NULL) { wmt_spi_lcd_printk("failed to allocate memory for module data\n"); return -ENOMEM; } spi_dev->spi = spi; spi_set_drvdata(spi, spi_dev); ret = wmt_spi_lcd_sysfs_create_group(spi_dev, &wmt_spi_lcd_group); if(ret < 0){ wmt_spi_lcd_printk("create sysfs group failed.\n"); goto exit_create_group; } /* init mutex and queues */ init_waitqueue_head(&spi_dev->read_wq); mutex_init(&spi_dev->read_mutex); spin_lock_init(&spi_dev->irq_enabled_lock); spi_dev->sub_lcd_misc_device.minor = MISC_DYNAMIC_MINOR; spi_dev->sub_lcd_misc_device.name = "wmt_spi_lcd"; spi_dev->sub_lcd_misc_device.fops = &wmt_spi_lcd_fops; ret = misc_register(&spi_dev->sub_lcd_misc_device); if (ret) { wmt_spi_lcd_printk("%s : misc_register failed\n", __FILE__); goto err_misc_register; } wmt_spi_lcd_pContext = spi_dev; return 0; err_misc_register: mutex_destroy(&spi_dev->read_mutex); kfree(spi_dev); err_exit: gpio_free(WMT_SPI_LCD_A0_PIN); exit_create_group: destroy_workqueue(&spi_dev->read_wq); return ret; } static int wmt_spi_lcd_remove(struct spi_device *spi) { struct wmt_spi_lcd_dev *spi_dev = wmt_spi_lcd_pContext; misc_deregister(&spi_dev->sub_lcd_misc_device); mutex_destroy(&spi_dev->read_mutex); gpio_free(WMT_SPI_LCD_A0_PIN); wmt_spi_lcd_sysfs_remove_group(spi_dev, &wmt_spi_lcd_group); kfree(spi_dev); return 0; } static int wmt_spi_lcd_suspend(struct spi_device *spi, pm_message_t mesg) { printk("%s\n",__func__); return 0; } static int wmt_spi_lcd_resume(struct spi_device *spi) { printk("%s\n",__func__); wmt_spi_lcd_reset(); wmt_spi_lcd_display_state_picture(); return 0; } static struct spi_driver wmt_spi_lcd_driver = { .driver = { .name = "wmt_spi_lcd", .bus = &spi_bus_type, .owner = THIS_MODULE, }, .probe = wmt_spi_lcd_probe, .remove = wmt_spi_lcd_remove, .suspend = wmt_spi_lcd_suspend, .resume = wmt_spi_lcd_resume, }; static struct spi_board_info wmt_spi_lcd_board_info[] __initdata = { { .modalias = "wmt_spi_lcd", .bus_num = 0, .chip_select = 0, .max_speed_hz = 12000000, .irq = -1, .mode = SPI_MODE_0, .controller_data = NULL, }, }; static int wmt_spi_lcd_register_device (void) { int ret = 0; ret = spi_register_board_info(wmt_spi_lcd_board_info, ARRAY_SIZE(wmt_spi_lcd_board_info)); return ret; } static int wmt_spi_lcd_init(void) { int ret = 0; unsigned char buf[40]; int buflen = 40; unsigned int value; char *endp; if(wmt_getsyspara("wmt.support.lcd.spi", buf, &buflen) == 0) { value = simple_strtoul(buf, &endp, 0); if(value == 0) return -1; } else return -1; if (wmt_spi_lcd_register_device()<0) { wmt_spi_lcd_printk(" Error to run wmt_spi_lcd_register_device()!\n"); return -1; } ret = spi_register_driver(&wmt_spi_lcd_driver); if (ret != 0) { wmt_spi_lcd_printk("failed to register wmt_spi_lcd SPI driver: %d\n", ret); goto out; } out: return ret; } static void wmt_spi_lcd_exit(void) { wmt_spi_lcd_printk("Unloading wmt_spi_lcd driver\n"); spi_unregister_driver(&wmt_spi_lcd_driver); } module_init(wmt_spi_lcd_init); module_exit(wmt_spi_lcd_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION(DRIVER_DESC);