linux/arch/arm/mach-sa1100/h3100.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-only
   2/*
   3 * Support for Compaq iPAQ H3100 handheld computer
   4 *
   5 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
   6 * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
   7 */
   8
   9#include <linux/init.h>
  10#include <linux/kernel.h>
  11#include <linux/gpio.h>
  12
  13#include <video/sa1100fb.h>
  14
  15#include <asm/mach-types.h>
  16#include <asm/mach/arch.h>
  17#include <linux/platform_data/irda-sa11x0.h>
  18
  19#include <mach/h3xxx.h>
  20#include <mach/irqs.h>
  21
  22#include "generic.h"
  23
  24/*
  25 * helper for sa1100fb
  26 */
  27static struct gpio h3100_lcd_gpio[] = {
  28        { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" },
  29        { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" },
  30};
  31
  32static bool h3100_lcd_request(void)
  33{
  34        static bool h3100_lcd_ok;
  35        int rc;
  36
  37        if (h3100_lcd_ok)
  38                return true;
  39
  40        rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio));
  41        if (rc)
  42                pr_err("%s: can't request GPIOs\n", __func__);
  43        else
  44                h3100_lcd_ok = true;
  45
  46        return h3100_lcd_ok;
  47}
  48
  49static void h3100_lcd_power(int enable)
  50{
  51        if (!h3100_lcd_request())
  52                return;
  53
  54        gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
  55        gpio_set_value(H3XXX_EGPIO_LCD_ON, enable);
  56}
  57
  58static struct sa1100fb_mach_info h3100_lcd_info = {
  59        .pixclock       = 406977,       .bpp            = 4,
  60        .xres           = 320,          .yres           = 240,
  61
  62        .hsync_len      = 26,           .vsync_len      = 41,
  63        .left_margin    = 4,            .upper_margin   = 0,
  64        .right_margin   = 4,            .lower_margin   = 0,
  65
  66        .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  67        .cmap_greyscale = 1,
  68        .cmap_inverse   = 1,
  69
  70        .lccr0          = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
  71        .lccr3          = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  72
  73        .lcd_power = h3100_lcd_power,
  74};
  75
  76static void __init h3100_map_io(void)
  77{
  78        h3xxx_map_io();
  79
  80        /* Older bootldrs put GPIO2-9 in alternate mode on the
  81           assumption that they are used for video */
  82        GAFR &= ~0x000001fb;
  83}
  84
  85/*
  86 * This turns the IRDA power on or off on the Compaq H3100
  87 */
  88static struct gpio h3100_irda_gpio[] = {
  89        { H3100_GPIO_IR_ON,     GPIOF_OUT_INIT_LOW, "IrDA power" },
  90        { H3100_GPIO_IR_FSEL,   GPIOF_OUT_INIT_LOW, "IrDA fsel" },
  91};
  92
  93static int h3100_irda_set_power(struct device *dev, unsigned int state)
  94{
  95        gpio_set_value(H3100_GPIO_IR_ON, state);
  96        return 0;
  97}
  98
  99static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
 100{
 101        gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
 102}
 103
 104static int h3100_irda_startup(struct device *dev)
 105{
 106        return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
 107}
 108
 109static void h3100_irda_shutdown(struct device *dev)
 110{
 111        return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
 112}
 113
 114static struct irda_platform_data h3100_irda_data = {
 115        .set_power      = h3100_irda_set_power,
 116        .set_speed      = h3100_irda_set_speed,
 117        .startup        = h3100_irda_startup,
 118        .shutdown       = h3100_irda_shutdown,
 119};
 120
 121static void __init h3100_mach_init(void)
 122{
 123        h3xxx_mach_init();
 124
 125        sa11x0_register_pcmcia(-1, NULL);
 126        sa11x0_register_lcd(&h3100_lcd_info);
 127        sa11x0_register_irda(&h3100_irda_data);
 128}
 129
 130MACHINE_START(H3100, "Compaq iPAQ H3100")
 131        .atag_offset    = 0x100,
 132        .map_io         = h3100_map_io,
 133        .nr_irqs        = SA1100_NR_IRQS,
 134        .init_irq       = sa1100_init_irq,
 135        .init_time      = sa1100_timer_init,
 136        .init_machine   = h3100_mach_init,
 137        .init_late      = sa11x0_init_late,
 138        .restart        = sa11x0_restart,
 139MACHINE_END
 140
 141