diff options
Diffstat (limited to 'arch/arm/common/locomo.c')
-rw-r--r-- | arch/arm/common/locomo.c | 61 |
1 files changed, 40 insertions, 21 deletions
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c index 4e0dcaef6eb2..181ef1ead5b8 100644 --- a/arch/arm/common/locomo.c +++ b/arch/arm/common/locomo.c | |||
@@ -121,6 +121,13 @@ static struct locomo_dev_info locomo_devices[] = { | |||
121 | .offset = 0, | 121 | .offset = 0, |
122 | .length = 0, | 122 | .length = 0, |
123 | }, | 123 | }, |
124 | { | ||
125 | .devid = LOCOMO_DEVID_SPI, | ||
126 | .irq = {}, | ||
127 | .name = "locomo-spi", | ||
128 | .offset = LOCOMO_SPI, | ||
129 | .length = 0x30, | ||
130 | }, | ||
124 | }; | 131 | }; |
125 | 132 | ||
126 | 133 | ||
@@ -374,7 +381,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc, | |||
374 | struct irqdesc *d; | 381 | struct irqdesc *d; |
375 | void __iomem *mapbase = get_irq_chipdata(irq); | 382 | void __iomem *mapbase = get_irq_chipdata(irq); |
376 | 383 | ||
377 | req = locomo_readl(mapbase + LOCOMO_SPIIR) & 0x000F; | 384 | req = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIR) & 0x000F; |
378 | if (req) { | 385 | if (req) { |
379 | irq = LOCOMO_IRQ_SPI_START; | 386 | irq = LOCOMO_IRQ_SPI_START; |
380 | d = irq_desc + irq; | 387 | d = irq_desc + irq; |
@@ -391,35 +398,35 @@ static void locomo_spi_ack_irq(unsigned int irq) | |||
391 | { | 398 | { |
392 | void __iomem *mapbase = get_irq_chipdata(irq); | 399 | void __iomem *mapbase = get_irq_chipdata(irq); |
393 | unsigned int r; | 400 | unsigned int r; |
394 | r = locomo_readl(mapbase + LOCOMO_SPIWE); | 401 | r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIWE); |
395 | r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); | 402 | r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); |
396 | locomo_writel(r, mapbase + LOCOMO_SPIWE); | 403 | locomo_writel(r, mapbase + LOCOMO_SPI + LOCOMO_SPIWE); |
397 | 404 | ||
398 | r = locomo_readl(mapbase + LOCOMO_SPIIS); | 405 | r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIS); |
399 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); | 406 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); |
400 | locomo_writel(r, mapbase + LOCOMO_SPIIS); | 407 | locomo_writel(r, mapbase + LOCOMO_SPI + LOCOMO_SPIIS); |
401 | 408 | ||
402 | r = locomo_readl(mapbase + LOCOMO_SPIWE); | 409 | r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIWE); |
403 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); | 410 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); |
404 | locomo_writel(r, mapbase + LOCOMO_SPIWE); | 411 | locomo_writel(r, mapbase + LOCOMO_SPI + LOCOMO_SPIWE); |
405 | } | 412 | } |
406 | 413 | ||
407 | static void locomo_spi_mask_irq(unsigned int irq) | 414 | static void locomo_spi_mask_irq(unsigned int irq) |
408 | { | 415 | { |
409 | void __iomem *mapbase = get_irq_chipdata(irq); | 416 | void __iomem *mapbase = get_irq_chipdata(irq); |
410 | unsigned int r; | 417 | unsigned int r; |
411 | r = locomo_readl(mapbase + LOCOMO_SPIIE); | 418 | r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIE); |
412 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); | 419 | r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START)); |
413 | locomo_writel(r, mapbase + LOCOMO_SPIIE); | 420 | locomo_writel(r, mapbase + LOCOMO_SPI + LOCOMO_SPIIE); |
414 | } | 421 | } |
415 | 422 | ||
416 | static void locomo_spi_unmask_irq(unsigned int irq) | 423 | static void locomo_spi_unmask_irq(unsigned int irq) |
417 | { | 424 | { |
418 | void __iomem *mapbase = get_irq_chipdata(irq); | 425 | void __iomem *mapbase = get_irq_chipdata(irq); |
419 | unsigned int r; | 426 | unsigned int r; |
420 | r = locomo_readl(mapbase + LOCOMO_SPIIE); | 427 | r = locomo_readl(mapbase + LOCOMO_SPI + LOCOMO_SPIIE); |
421 | r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); | 428 | r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START)); |
422 | locomo_writel(r, mapbase + LOCOMO_SPIIE); | 429 | locomo_writel(r, mapbase + LOCOMO_SPI + LOCOMO_SPIIE); |
423 | } | 430 | } |
424 | 431 | ||
425 | static struct irq_chip locomo_spi_chip = { | 432 | static struct irq_chip locomo_spi_chip = { |
@@ -814,12 +821,15 @@ static inline struct locomo *locomo_chip_driver(struct locomo_dev *ldev) | |||
814 | return (struct locomo *)dev_get_drvdata(ldev->dev.parent); | 821 | return (struct locomo *)dev_get_drvdata(ldev->dev.parent); |
815 | } | 822 | } |
816 | 823 | ||
817 | void locomo_gpio_set_dir(struct locomo_dev *ldev, unsigned int bits, unsigned int dir) | 824 | void locomo_gpio_set_dir(struct device *dev, unsigned int bits, unsigned int dir) |
818 | { | 825 | { |
819 | struct locomo *lchip = locomo_chip_driver(ldev); | 826 | struct locomo *lchip = dev_get_drvdata(dev); |
820 | unsigned long flags; | 827 | unsigned long flags; |
821 | unsigned int r; | 828 | unsigned int r; |
822 | 829 | ||
830 | if (!lchip) | ||
831 | return; | ||
832 | |||
823 | spin_lock_irqsave(&lchip->lock, flags); | 833 | spin_lock_irqsave(&lchip->lock, flags); |
824 | 834 | ||
825 | r = locomo_readl(lchip->base + LOCOMO_GPD); | 835 | r = locomo_readl(lchip->base + LOCOMO_GPD); |
@@ -836,12 +846,15 @@ void locomo_gpio_set_dir(struct locomo_dev *ldev, unsigned int bits, unsigned in | |||
836 | spin_unlock_irqrestore(&lchip->lock, flags); | 846 | spin_unlock_irqrestore(&lchip->lock, flags); |
837 | } | 847 | } |
838 | 848 | ||
839 | unsigned int locomo_gpio_read_level(struct locomo_dev *ldev, unsigned int bits) | 849 | int locomo_gpio_read_level(struct device *dev, unsigned int bits) |
840 | { | 850 | { |
841 | struct locomo *lchip = locomo_chip_driver(ldev); | 851 | struct locomo *lchip = dev_get_drvdata(dev); |
842 | unsigned long flags; | 852 | unsigned long flags; |
843 | unsigned int ret; | 853 | unsigned int ret; |
844 | 854 | ||
855 | if (!lchip) | ||
856 | return -ENODEV; | ||
857 | |||
845 | spin_lock_irqsave(&lchip->lock, flags); | 858 | spin_lock_irqsave(&lchip->lock, flags); |
846 | ret = locomo_readl(lchip->base + LOCOMO_GPL); | 859 | ret = locomo_readl(lchip->base + LOCOMO_GPL); |
847 | spin_unlock_irqrestore(&lchip->lock, flags); | 860 | spin_unlock_irqrestore(&lchip->lock, flags); |
@@ -850,12 +863,15 @@ unsigned int locomo_gpio_read_level(struct locomo_dev *ldev, unsigned int bits) | |||
850 | return ret; | 863 | return ret; |
851 | } | 864 | } |
852 | 865 | ||
853 | unsigned int locomo_gpio_read_output(struct locomo_dev *ldev, unsigned int bits) | 866 | int locomo_gpio_read_output(struct device *dev, unsigned int bits) |
854 | { | 867 | { |
855 | struct locomo *lchip = locomo_chip_driver(ldev); | 868 | struct locomo *lchip = dev_get_drvdata(dev); |
856 | unsigned long flags; | 869 | unsigned long flags; |
857 | unsigned int ret; | 870 | unsigned int ret; |
858 | 871 | ||
872 | if (!lchip) | ||
873 | return -ENODEV; | ||
874 | |||
859 | spin_lock_irqsave(&lchip->lock, flags); | 875 | spin_lock_irqsave(&lchip->lock, flags); |
860 | ret = locomo_readl(lchip->base + LOCOMO_GPO); | 876 | ret = locomo_readl(lchip->base + LOCOMO_GPO); |
861 | spin_unlock_irqrestore(&lchip->lock, flags); | 877 | spin_unlock_irqrestore(&lchip->lock, flags); |
@@ -864,12 +880,15 @@ unsigned int locomo_gpio_read_output(struct locomo_dev *ldev, unsigned int bits) | |||
864 | return ret; | 880 | return ret; |
865 | } | 881 | } |
866 | 882 | ||
867 | void locomo_gpio_write(struct locomo_dev *ldev, unsigned int bits, unsigned int set) | 883 | void locomo_gpio_write(struct device *dev, unsigned int bits, unsigned int set) |
868 | { | 884 | { |
869 | struct locomo *lchip = locomo_chip_driver(ldev); | 885 | struct locomo *lchip = dev_get_drvdata(dev); |
870 | unsigned long flags; | 886 | unsigned long flags; |
871 | unsigned int r; | 887 | unsigned int r; |
872 | 888 | ||
889 | if (!lchip) | ||
890 | return; | ||
891 | |||
873 | spin_lock_irqsave(&lchip->lock, flags); | 892 | spin_lock_irqsave(&lchip->lock, flags); |
874 | 893 | ||
875 | r = locomo_readl(lchip->base + LOCOMO_GPO); | 894 | r = locomo_readl(lchip->base + LOCOMO_GPO); |
@@ -1058,9 +1077,9 @@ void locomo_frontlight_set(struct locomo_dev *dev, int duty, int vr, int bpwf) | |||
1058 | struct locomo *lchip = locomo_chip_driver(dev); | 1077 | struct locomo *lchip = locomo_chip_driver(dev); |
1059 | 1078 | ||
1060 | if (vr) | 1079 | if (vr) |
1061 | locomo_gpio_write(dev, LOCOMO_GPIO_FL_VR, 1); | 1080 | locomo_gpio_write(dev->dev.parent, LOCOMO_GPIO_FL_VR, 1); |
1062 | else | 1081 | else |
1063 | locomo_gpio_write(dev, LOCOMO_GPIO_FL_VR, 0); | 1082 | locomo_gpio_write(dev->dev.parent, LOCOMO_GPIO_FL_VR, 0); |
1064 | 1083 | ||
1065 | spin_lock_irqsave(&lchip->lock, flags); | 1084 | spin_lock_irqsave(&lchip->lock, flags); |
1066 | locomo_writel(bpwf, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS); | 1085 | locomo_writel(bpwf, lchip->base + LOCOMO_FRONTLIGHT + LOCOMO_ALS); |