^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * am300epd.c -- Platform device for AM300 EPD kit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2008, Jaya Kumar
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * License. See the file COPYING in the main directory of this archive for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This work was made possible by help and equipment support from E-Ink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Corporation. http://support.eink.com/community
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This driver is written to be used with the Broadsheet display controller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * on the AM300 EPD prototype kit/development kit with an E-Ink 800x600
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * Vizplex EPD on a Gumstix board using the Broadsheet interface board.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "gumstix.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "mfp-pxa25x.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <mach/irqs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <linux/platform_data/video-pxafb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "generic.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include <video/broadsheetfb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static unsigned int panel_type = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static struct platform_device *am300_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static struct broadsheet_board am300_board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) static unsigned long am300_pin_config[] __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) GPIO16_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) GPIO17_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) GPIO32_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) GPIO48_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) GPIO49_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) GPIO51_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) GPIO74_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) GPIO75_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) GPIO76_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) GPIO77_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) /* this is the 16-bit hdb bus 58-73 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) GPIO58_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) GPIO59_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) GPIO60_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) GPIO61_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) GPIO62_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) GPIO63_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) GPIO64_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) GPIO65_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) GPIO66_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) GPIO67_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) GPIO68_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) GPIO69_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) GPIO70_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) GPIO71_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) GPIO72_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) GPIO73_GPIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* register offsets for gpio control */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define PWR_GPIO_PIN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define CFG_GPIO_PIN 17
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define RDY_GPIO_PIN 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define DC_GPIO_PIN 48
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define RST_GPIO_PIN 49
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define LED_GPIO_PIN 51
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define RD_GPIO_PIN 74
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define WR_GPIO_PIN 75
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define CS_GPIO_PIN 76
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define IRQ_GPIO_PIN 77
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* hdb bus */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define DB0_GPIO_PIN 58
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define DB15_GPIO_PIN 73
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) static int gpios[] = { PWR_GPIO_PIN, CFG_GPIO_PIN, RDY_GPIO_PIN, DC_GPIO_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) RST_GPIO_PIN, RD_GPIO_PIN, WR_GPIO_PIN, CS_GPIO_PIN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) IRQ_GPIO_PIN, LED_GPIO_PIN };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static char *gpio_names[] = { "PWR", "CFG", "RDY", "DC", "RST", "RD", "WR",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) "CS", "IRQ", "LED" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) static int am300_wait_event(struct broadsheetfb_par *par)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /* todo: improve err recovery */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) wait_event(par->waitq, gpio_get_value(RDY_GPIO_PIN));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static int am300_init_gpio_regs(struct broadsheetfb_par *par)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) char dbname[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) for (i = 0; i < ARRAY_SIZE(gpios); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) err = gpio_request(gpios[i], gpio_names[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) dev_err(&am300_device->dev, "failed requesting "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) "gpio %s, err=%d\n", gpio_names[i], err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) goto err_req_gpio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /* we also need to take care of the hdb bus */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) for (i = DB0_GPIO_PIN; i <= DB15_GPIO_PIN; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) sprintf(dbname, "DB%d", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) err = gpio_request(i, dbname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) dev_err(&am300_device->dev, "failed requesting "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) "gpio %d, err=%d\n", i, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) goto err_req_gpio2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /* setup the outputs and init values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) gpio_direction_output(PWR_GPIO_PIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) gpio_direction_output(CFG_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) gpio_direction_output(DC_GPIO_PIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) gpio_direction_output(RD_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) gpio_direction_output(WR_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) gpio_direction_output(CS_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) gpio_direction_output(RST_GPIO_PIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /* setup the inputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) gpio_direction_input(RDY_GPIO_PIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) gpio_direction_input(IRQ_GPIO_PIN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* start the hdb bus as an input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) for (i = DB0_GPIO_PIN; i <= DB15_GPIO_PIN; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) gpio_direction_output(i, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) /* go into command mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) gpio_set_value(CFG_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) gpio_set_value(RST_GPIO_PIN, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) gpio_set_value(RST_GPIO_PIN, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) msleep(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) am300_wait_event(par);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) err_req_gpio2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) while (--i >= DB0_GPIO_PIN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) gpio_free(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) i = ARRAY_SIZE(gpios);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) err_req_gpio:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) while (--i >= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) gpio_free(gpios[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static int am300_init_board(struct broadsheetfb_par *par)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return am300_init_gpio_regs(par);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static void am300_cleanup(struct broadsheetfb_par *par)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) free_irq(PXA_GPIO_TO_IRQ(RDY_GPIO_PIN), par);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) for (i = 0; i < ARRAY_SIZE(gpios); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) gpio_free(gpios[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) for (i = DB0_GPIO_PIN; i <= DB15_GPIO_PIN; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) gpio_free(i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) static u16 am300_get_hdb(struct broadsheetfb_par *par)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u16 res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) for (i = 0; i <= (DB15_GPIO_PIN - DB0_GPIO_PIN) ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) res |= (gpio_get_value(DB0_GPIO_PIN + i)) ? (1 << i) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void am300_set_hdb(struct broadsheetfb_par *par, u16 data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) for (i = 0; i <= (DB15_GPIO_PIN - DB0_GPIO_PIN) ; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) gpio_set_value(DB0_GPIO_PIN + i, (data >> i) & 0x01);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static void am300_set_ctl(struct broadsheetfb_par *par, unsigned char bit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) u8 state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) switch (bit) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) case BS_CS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) gpio_set_value(CS_GPIO_PIN, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) case BS_DC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) gpio_set_value(DC_GPIO_PIN, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) case BS_WR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) gpio_set_value(WR_GPIO_PIN, state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static int am300_get_panel_type(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return panel_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static irqreturn_t am300_handle_irq(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct broadsheetfb_par *par = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) wake_up(&par->waitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int am300_setup_irq(struct fb_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) struct broadsheetfb_par *par = info->par;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ret = request_irq(PXA_GPIO_TO_IRQ(RDY_GPIO_PIN), am300_handle_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) IRQF_TRIGGER_RISING, "AM300", par);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) dev_err(&am300_device->dev, "request_irq failed: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static struct broadsheet_board am300_board = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) .init = am300_init_board,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) .cleanup = am300_cleanup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) .set_hdb = am300_set_hdb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) .get_hdb = am300_get_hdb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) .set_ctl = am300_set_ctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) .wait_for_rdy = am300_wait_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .get_panel_type = am300_get_panel_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .setup_irq = am300_setup_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int __init am300_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) pxa2xx_mfp_config(ARRAY_AND_SIZE(am300_pin_config));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* request our platform independent driver */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) request_module("broadsheetfb");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) am300_device = platform_device_alloc("broadsheetfb", -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (!am300_device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /* the am300_board that will be seen by broadsheetfb is a copy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) platform_device_add_data(am300_device, &am300_board,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) sizeof(am300_board));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) ret = platform_device_add(am300_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) platform_device_put(am300_device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) module_param(panel_type, uint, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) MODULE_PARM_DESC(panel_type, "Select the panel type: 37, 6, 97");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) MODULE_DESCRIPTION("board driver for am300 epd kit");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) MODULE_AUTHOR("Jaya Kumar");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) MODULE_LICENSE("GPL");