^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/arch/arm/common/locomo.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Sharp LoCoMo support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This file contains all generic LoCoMo support.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * All initialization functions provided here are intended to be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * from machine specific code with proper arguments when required.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Based on sa1111.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <mach/hardware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <asm/mach/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <asm/hardware/locomo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /* LoCoMo Interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define IRQ_LOCOMO_KEY (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define IRQ_LOCOMO_GPIO (1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define IRQ_LOCOMO_LT (2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define IRQ_LOCOMO_SPI (3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* M62332 output channel selection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define M62332_EVR_CH 1 /* M62332 volume channel number */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* 0 : CH.1 , 1 : CH. 2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* DAC send data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define M62332_SLAVE_ADDR 0x4e /* Slave address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define M62332_W_BIT 0x00 /* W bit (0 only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define M62332_SUB_ADDR 0x00 /* Sub address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define M62332_A_BIT 0x00 /* A bit (0 only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* DAC setup and hold times (expressed in us) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define DAC_BUS_FREE_TIME 5 /* 4.7 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define DAC_START_SETUP_TIME 5 /* 4.7 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define DAC_STOP_SETUP_TIME 4 /* 4.0 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define DAC_START_HOLD_TIME 5 /* 4.7 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define DAC_SCL_LOW_HOLD_TIME 5 /* 4.7 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define DAC_SCL_HIGH_HOLD_TIME 4 /* 4.0 us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define DAC_DATA_SETUP_TIME 1 /* 250 ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define DAC_DATA_HOLD_TIME 1 /* 300 ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define DAC_LOW_SETUP_TIME 1 /* 300 ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define DAC_HIGH_SETUP_TIME 1 /* 1000 ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) /* the following is the overall data for the locomo chip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct locomo {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) unsigned long phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int irq_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) void *saved_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) struct locomo_dev_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) unsigned long length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned int devid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned int irq[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) const char * name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* All the locomo devices. If offset is non-zero, the mapbase for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * locomo_dev will be set to the chip base plus offset. If offset is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) * zero, then the mapbase for the locomo_dev will be set to zero. An
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * offset of zero means the device only uses GPIOs or other helper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * functions inside this file */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) static struct locomo_dev_info locomo_devices[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) .devid = LOCOMO_DEVID_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) .irq = { IRQ_LOCOMO_KEY },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) .name = "locomo-keyboard",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .offset = LOCOMO_KEYBOARD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .length = 16,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) .devid = LOCOMO_DEVID_FRONTLIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) .name = "locomo-frontlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) .offset = LOCOMO_FRONTLIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) .length = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) .devid = LOCOMO_DEVID_BACKLIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) .name = "locomo-backlight",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) .offset = LOCOMO_BACKLIGHT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) .length = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) .devid = LOCOMO_DEVID_AUDIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) .name = "locomo-audio",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) .offset = LOCOMO_AUDIO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) .length = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) .devid = LOCOMO_DEVID_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) .name = "locomo-led",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) .offset = LOCOMO_LED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) .length = 8,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) .devid = LOCOMO_DEVID_UART,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) .name = "locomo-uart",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) .offset = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) .length = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) .devid = LOCOMO_DEVID_SPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) .irq = {},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) .name = "locomo-spi",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) .offset = LOCOMO_SPI,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) .length = 0x30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static void locomo_handler(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct locomo *lchip = irq_desc_get_handler_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int req, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* Acknowledge the parent IRQ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) desc->irq_data.chip->irq_ack(&desc->irq_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* check why this interrupt was generated */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) req = locomo_readl(lchip->base + LOCOMO_ICR) & 0x0f00;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) if (req) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /* generate the next interrupt(s) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) irq = lchip->irq_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) for (i = 0; i <= 3; i++, irq++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (req & (0x0100 << i)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) generic_handle_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) static void locomo_ack_irq(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static void locomo_mask_irq(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct locomo *lchip = irq_data_get_irq_chip_data(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) r = locomo_readl(lchip->base + LOCOMO_ICR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) r &= ~(0x0010 << (d->irq - lchip->irq_base));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) locomo_writel(r, lchip->base + LOCOMO_ICR);
^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 locomo_unmask_irq(struct irq_data *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct locomo *lchip = irq_data_get_irq_chip_data(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) r = locomo_readl(lchip->base + LOCOMO_ICR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) r |= (0x0010 << (d->irq - lchip->irq_base));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) locomo_writel(r, lchip->base + LOCOMO_ICR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) static struct irq_chip locomo_chip = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) .name = "LOCOMO",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) .irq_ack = locomo_ack_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) .irq_mask = locomo_mask_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) .irq_unmask = locomo_unmask_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static void locomo_setup_irq(struct locomo *lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int irq = lchip->irq_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) * Install handler for IRQ_LOCOMO_HW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) irq_set_irq_type(lchip->irq, IRQ_TYPE_EDGE_FALLING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) irq_set_chained_handler_and_data(lchip->irq, locomo_handler, lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) /* Install handlers for IRQ_LOCOMO_* */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) for ( ; irq <= lchip->irq_base + 3; irq++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) irq_set_chip_and_handler(irq, &locomo_chip, handle_level_irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) irq_set_chip_data(irq, lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) irq_clear_status_flags(irq, IRQ_NOREQUEST | IRQ_NOPROBE);
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static void locomo_dev_release(struct device *_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct locomo_dev *dev = LOCOMO_DEV(_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) kfree(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct locomo_dev *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!dev) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^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) * If the parent device has a DMA mask associated with it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * propagate it down to the children.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) if (lchip->dev->dma_mask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) dev->dma_mask = *lchip->dev->dma_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) dev->dev.dma_mask = &dev->dma_mask;
^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) dev_set_name(&dev->dev, "%s", info->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) dev->devid = info->devid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) dev->dev.parent = lchip->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) dev->dev.bus = &locomo_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) dev->dev.release = locomo_dev_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) dev->dev.coherent_dma_mask = lchip->dev->coherent_dma_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (info->offset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) dev->mapbase = lchip->base + info->offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) dev->mapbase = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) dev->length = info->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) dev->irq[0] = (lchip->irq_base == NO_IRQ) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) NO_IRQ : lchip->irq_base + info->irq[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) ret = device_register(&dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) kfree(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct locomo_save_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) u16 LCM_GPO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) u16 LCM_SPICT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) u16 LCM_GPE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) u16 LCM_ASD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) u16 LCM_SPIMD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static int locomo_suspend(struct platform_device *dev, pm_message_t state)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) struct locomo *lchip = platform_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct locomo_save_data *save;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) if (!save)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) lchip->saved_state = save;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) save->LCM_GPO = locomo_readl(lchip->base + LOCOMO_GPO); /* GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) locomo_writel(0x00, lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) save->LCM_SPICT = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPICT); /* SPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) locomo_writel(0x40, lchip->base + LOCOMO_SPI + LOCOMO_SPICT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) save->LCM_GPE = locomo_readl(lchip->base + LOCOMO_GPE); /* GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) locomo_writel(0x00, lchip->base + LOCOMO_GPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) save->LCM_ASD = locomo_readl(lchip->base + LOCOMO_ASD); /* ADSTART */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) locomo_writel(0x00, lchip->base + LOCOMO_ASD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) save->LCM_SPIMD = locomo_readl(lchip->base + LOCOMO_SPI + LOCOMO_SPIMD); /* SPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) locomo_writel(0x3C14, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) locomo_writel(0x00, lchip->base + LOCOMO_PAIF);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) locomo_writel(0x00, lchip->base + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) locomo_writel(0x00, lchip->base + LOCOMO_BACKLIGHT + LOCOMO_TC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) if ((locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT0) & 0x88) && (locomo_readl(lchip->base + LOCOMO_LED + LOCOMO_LPT1) & 0x88))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) locomo_writel(0x00, lchip->base + LOCOMO_C32K); /* CLK32 off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) /* 18MHz already enabled, so no wait */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) locomo_writel(0xc1, lchip->base + LOCOMO_C32K); /* CLK32 on */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) locomo_writel(0x00, lchip->base + LOCOMO_TADC); /* 18MHz clock off*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) locomo_writel(0x00, lchip->base + LOCOMO_AUDIO + LOCOMO_ACC); /* 22MHz/24MHz clock off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) locomo_writel(0x00, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS); /* FL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) static int locomo_resume(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) struct locomo *lchip = platform_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) struct locomo_save_data *save;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsigned long r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) save = lchip->saved_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) if (!save)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) locomo_writel(save->LCM_GPO, lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) locomo_writel(save->LCM_SPICT, lchip->base + LOCOMO_SPI + LOCOMO_SPICT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) locomo_writel(save->LCM_GPE, lchip->base + LOCOMO_GPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) locomo_writel(save->LCM_ASD, lchip->base + LOCOMO_ASD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) locomo_writel(save->LCM_SPIMD, lchip->base + LOCOMO_SPI + LOCOMO_SPIMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) locomo_writel(0x00, lchip->base + LOCOMO_C32K);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) locomo_writel(0x90, lchip->base + LOCOMO_TADC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) locomo_writel(0, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KSC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) r = locomo_readl(lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) r &= 0xFEFF;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) locomo_writel(r, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) locomo_writel(0x1, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KCMD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) lchip->saved_state = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) kfree(save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * locomo_probe - probe for a single LoCoMo chip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * @phys_addr: physical address of device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * Probe for a LoCoMo chip. This must be called
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * before any other locomo-specific code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) * %-ENODEV device not found.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) * %-EBUSY physical address already marked in-use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) * %0 successful.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) __locomo_probe(struct device *me, struct resource *mem, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) struct locomo_platform_data *pdata = me->platform_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct locomo *lchip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) unsigned long r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) int i, ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) lchip = kzalloc(sizeof(struct locomo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) if (!lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) spin_lock_init(&lchip->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) lchip->dev = me;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) dev_set_drvdata(lchip->dev, lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) lchip->phys = mem->start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) lchip->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) lchip->irq_base = (pdata) ? pdata->irq_base : NO_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) * Map the whole region. This also maps the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) * registers for our children.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) lchip->base = ioremap(mem->start, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) if (!lchip->base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) /* locomo initialize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) locomo_writel(0, lchip->base + LOCOMO_ICR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) /* KEYBOARD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) locomo_writel(0, lchip->base + LOCOMO_KEYBOARD + LOCOMO_KIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) /* GPIO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) locomo_writel(0, lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) , lchip->base + LOCOMO_GPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) locomo_writel((LOCOMO_GPIO(1) | LOCOMO_GPIO(2) | LOCOMO_GPIO(13) | LOCOMO_GPIO(14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) , lchip->base + LOCOMO_GPD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) locomo_writel(0, lchip->base + LOCOMO_GIE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) /* Frontlight */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) locomo_writel(0, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) locomo_writel(0, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) /* Longtime timer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) locomo_writel(0, lchip->base + LOCOMO_LTINT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* SPI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) locomo_writel(0, lchip->base + LOCOMO_SPI + LOCOMO_SPIIE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) locomo_writel(6 + 8 + 320 + 30 - 10, lchip->base + LOCOMO_ASD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) r = locomo_readl(lchip->base + LOCOMO_ASD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) r |= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) locomo_writel(r, lchip->base + LOCOMO_ASD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) locomo_writel(6 + 8 + 320 + 30 - 10 - 128 + 4, lchip->base + LOCOMO_HSD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) r = locomo_readl(lchip->base + LOCOMO_HSD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) r |= 0x8000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) locomo_writel(r, lchip->base + LOCOMO_HSD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) locomo_writel(128 / 8, lchip->base + LOCOMO_HSC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) /* XON */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) locomo_writel(0x80, lchip->base + LOCOMO_TADC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) udelay(1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /* CLK9MEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) r = locomo_readl(lchip->base + LOCOMO_TADC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) r |= 0x10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) locomo_writel(r, lchip->base + LOCOMO_TADC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) udelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) /* init DAC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) r = locomo_readl(lchip->base + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) r |= LOCOMO_DAC_SCLOEB | LOCOMO_DAC_SDAOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) locomo_writel(r, lchip->base + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) r = locomo_readl(lchip->base + LOCOMO_VER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) printk(KERN_INFO "LoCoMo Chip: %lu%lu\n", (r >> 8), (r & 0xff));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) * The interrupt controller must be initialised before any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) * other device to ensure that the interrupts are available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (lchip->irq != NO_IRQ && lchip->irq_base != NO_IRQ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) locomo_setup_irq(lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) for (i = 0; i < ARRAY_SIZE(locomo_devices); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) locomo_init_one_child(lchip, &locomo_devices[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) kfree(lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) static int locomo_remove_child(struct device *dev, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) device_unregister(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) static void __locomo_remove(struct locomo *lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) device_for_each_child(lchip->dev, NULL, locomo_remove_child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) if (lchip->irq != NO_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) irq_set_chained_handler_and_data(lchip->irq, NULL, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) iounmap(lchip->base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) kfree(lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) static int locomo_probe(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) struct resource *mem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) if (!mem)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) irq = platform_get_irq(dev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) if (irq < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) return __locomo_probe(&dev->dev, mem, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) static int locomo_remove(struct platform_device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) struct locomo *lchip = platform_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) if (lchip) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) __locomo_remove(lchip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) platform_set_drvdata(dev, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * Not sure if this should be on the system bus or not yet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * We really want some way to register a system device at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * the per-machine level, and then have this driver pick
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * up the registered devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) static struct platform_driver locomo_device_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) .probe = locomo_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) .remove = locomo_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) #ifdef CONFIG_PM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) .suspend = locomo_suspend,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) .resume = locomo_resume,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) .name = "locomo",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * Get the parent device driver (us) structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * from a child function device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) static inline struct locomo *locomo_chip_driver(struct locomo_dev *ldev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) return (struct locomo *)dev_get_drvdata(ldev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct locomo *lchip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) if (!lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) r = locomo_readl(lchip->base + LOCOMO_GPD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) if (dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) r |= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) r &= ~bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) locomo_writel(r, lchip->base + LOCOMO_GPD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) r = locomo_readl(lchip->base + LOCOMO_GPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) if (dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) r |= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) r &= ~bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) locomo_writel(r, lchip->base + LOCOMO_GPE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) EXPORT_SYMBOL(locomo_gpio_set_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) int locomo_gpio_read_level(struct device *dev, unsigned int bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) struct locomo *lchip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) unsigned int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) if (!lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) ret = locomo_readl(lchip->base + LOCOMO_GPL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) ret &= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) EXPORT_SYMBOL(locomo_gpio_read_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) int locomo_gpio_read_output(struct device *dev, unsigned int bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) struct locomo *lchip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) unsigned int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) if (!lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) ret = locomo_readl(lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) ret &= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) EXPORT_SYMBOL(locomo_gpio_read_output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) void locomo_gpio_write(struct device *dev, unsigned int bits, unsigned int set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) struct locomo *lchip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) if (!lchip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) r = locomo_readl(lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) if (set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) r |= bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) r &= ~bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) locomo_writel(r, lchip->base + LOCOMO_GPO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) EXPORT_SYMBOL(locomo_gpio_write);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) static void locomo_m62332_sendbit(void *mapbase, int bit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) udelay(DAC_DATA_HOLD_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (bit & 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) r |= LOCOMO_DAC_SDAOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) r &= ~(LOCOMO_DAC_SDAOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) udelay(DAC_DATA_SETUP_TIME); /* 250 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) r |= LOCOMO_DAC_SCLOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.0 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) void locomo_m62332_senddata(struct locomo_dev *ldev, unsigned int dac_data, int channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) struct locomo *lchip = locomo_chip_driver(ldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) unsigned char data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) unsigned int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) void *mapbase = lchip->base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) /* Start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) udelay(DAC_BUS_FREE_TIME); /* 5.0 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) r |= LOCOMO_DAC_SCLOEB | LOCOMO_DAC_SDAOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.0 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) r &= ~(LOCOMO_DAC_SDAOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) udelay(DAC_START_HOLD_TIME); /* 5.0 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) udelay(DAC_DATA_HOLD_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) /* Send slave address and W bit (LSB is W bit) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) data = (M62332_SLAVE_ADDR << 1) | M62332_W_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) for (i = 1; i <= 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) locomo_m62332_sendbit(mapbase, data >> (8 - i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) /* Check A bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) r &= ~(LOCOMO_DAC_SDAOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) r |= LOCOMO_DAC_SCLOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) { /* High is error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) printk(KERN_WARNING "locomo: m62332_senddata Error 1\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) /* Send Sub address (LSB is channel select) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) /* channel = 0 : ch1 select */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) /* = 1 : ch2 select */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) data = M62332_SUB_ADDR + channel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) for (i = 1; i <= 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) locomo_m62332_sendbit(mapbase, data >> (8 - i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /* Check A bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) r &= ~(LOCOMO_DAC_SDAOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) r |= LOCOMO_DAC_SCLOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) { /* High is error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) printk(KERN_WARNING "locomo: m62332_senddata Error 2\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) /* Send DAC data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) for (i = 1; i <= 8; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) locomo_m62332_sendbit(mapbase, dac_data >> (8 - i));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) /* Check A bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) r &= ~(LOCOMO_DAC_SDAOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) r |= LOCOMO_DAC_SCLOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) if (locomo_readl(mapbase + LOCOMO_DAC) & LOCOMO_DAC_SDAOEB) { /* High is error */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) printk(KERN_WARNING "locomo: m62332_senddata Error 3\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) /* stop */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) r &= ~(LOCOMO_DAC_SCLOEB);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) udelay(DAC_LOW_SETUP_TIME); /* 300 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) r |= LOCOMO_DAC_SCLOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) r |= LOCOMO_DAC_SDAOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) udelay(DAC_HIGH_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) udelay(DAC_SCL_HIGH_HOLD_TIME); /* 4 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) r = locomo_readl(mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) r |= LOCOMO_DAC_SCLOEB | LOCOMO_DAC_SDAOEB;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) locomo_writel(r, mapbase + LOCOMO_DAC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) udelay(DAC_LOW_SETUP_TIME); /* 1000 nsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) udelay(DAC_SCL_LOW_HOLD_TIME); /* 4.7 usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) EXPORT_SYMBOL(locomo_m62332_senddata);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) * Frontlight control
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) struct locomo *lchip = locomo_chip_driver(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) if (vr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) locomo_gpio_write(dev->dev.parent, LOCOMO_GPIO_FL_VR, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) locomo_gpio_write(dev->dev.parent, LOCOMO_GPIO_FL_VR, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) spin_lock_irqsave(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) locomo_writel(bpwf, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) udelay(100);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) locomo_writel(duty, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) locomo_writel(bpwf | LOCOMO_ALC_EN, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) spin_unlock_irqrestore(&lchip->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) EXPORT_SYMBOL(locomo_frontlight_set);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) * LoCoMo "Register Access Bus."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) * We model this as a regular bus type, and hang devices directly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) * off this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) static int locomo_match(struct device *_dev, struct device_driver *_drv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) struct locomo_dev *dev = LOCOMO_DEV(_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) struct locomo_driver *drv = LOCOMO_DRV(_drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) return dev->devid == drv->devid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) static int locomo_bus_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) struct locomo_dev *ldev = LOCOMO_DEV(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) int ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) if (drv->probe)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) ret = drv->probe(ldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) static int locomo_bus_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) struct locomo_dev *ldev = LOCOMO_DEV(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) struct locomo_driver *drv = LOCOMO_DRV(dev->driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) if (drv->remove)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) ret = drv->remove(ldev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) struct bus_type locomo_bus_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) .name = "locomo-bus",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) .match = locomo_match,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) .probe = locomo_bus_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) .remove = locomo_bus_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) int locomo_driver_register(struct locomo_driver *driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) driver->drv.bus = &locomo_bus_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) return driver_register(&driver->drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) EXPORT_SYMBOL(locomo_driver_register);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) void locomo_driver_unregister(struct locomo_driver *driver)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) driver_unregister(&driver->drv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) EXPORT_SYMBOL(locomo_driver_unregister);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) static int __init locomo_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) int ret = bus_register(&locomo_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) if (ret == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) platform_driver_register(&locomo_device_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) static void __exit locomo_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) platform_driver_unregister(&locomo_device_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) bus_unregister(&locomo_bus_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) module_init(locomo_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) module_exit(locomo_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) MODULE_DESCRIPTION("Sharp LoCoMo core driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");