Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Support for Compaq iPAQ H3100 handheld computer
0004  *
0005  * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
0006  * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
0007  */
0008 
0009 #include <linux/init.h>
0010 #include <linux/kernel.h>
0011 #include <linux/gpio.h>
0012 
0013 #include <video/sa1100fb.h>
0014 
0015 #include <asm/mach-types.h>
0016 #include <asm/mach/arch.h>
0017 #include <linux/platform_data/irda-sa11x0.h>
0018 
0019 #include <mach/h3xxx.h>
0020 #include <mach/irqs.h>
0021 
0022 #include "generic.h"
0023 
0024 /*
0025  * helper for sa1100fb
0026  */
0027 static struct gpio h3100_lcd_gpio[] = {
0028     { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" },
0029     { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" },
0030 };
0031 
0032 static bool h3100_lcd_request(void)
0033 {
0034     static bool h3100_lcd_ok;
0035     int rc;
0036 
0037     if (h3100_lcd_ok)
0038         return true;
0039 
0040     rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio));
0041     if (rc)
0042         pr_err("%s: can't request GPIOs\n", __func__);
0043     else
0044         h3100_lcd_ok = true;
0045 
0046     return h3100_lcd_ok;
0047 }
0048 
0049 static void h3100_lcd_power(int enable)
0050 {
0051     if (!h3100_lcd_request())
0052         return;
0053 
0054     gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
0055     gpio_set_value(H3XXX_EGPIO_LCD_ON, enable);
0056 }
0057 
0058 static struct sa1100fb_mach_info h3100_lcd_info = {
0059     .pixclock   = 406977,   .bpp        = 4,
0060     .xres       = 320,      .yres       = 240,
0061 
0062     .hsync_len  = 26,       .vsync_len  = 41,
0063     .left_margin    = 4,        .upper_margin   = 0,
0064     .right_margin   = 4,        .lower_margin   = 0,
0065 
0066     .sync       = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
0067     .cmap_greyscale = 1,
0068     .cmap_inverse   = 1,
0069 
0070     .lccr0      = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
0071     .lccr3      = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
0072 
0073     .lcd_power = h3100_lcd_power,
0074 };
0075 
0076 static void __init h3100_map_io(void)
0077 {
0078     h3xxx_map_io();
0079 
0080     /* Older bootldrs put GPIO2-9 in alternate mode on the
0081        assumption that they are used for video */
0082     GAFR &= ~0x000001fb;
0083 }
0084 
0085 /*
0086  * This turns the IRDA power on or off on the Compaq H3100
0087  */
0088 static struct gpio h3100_irda_gpio[] = {
0089     { H3100_GPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
0090     { H3100_GPIO_IR_FSEL,   GPIOF_OUT_INIT_LOW, "IrDA fsel" },
0091 };
0092 
0093 static int h3100_irda_set_power(struct device *dev, unsigned int state)
0094 {
0095     gpio_set_value(H3100_GPIO_IR_ON, state);
0096     return 0;
0097 }
0098 
0099 static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
0100 {
0101     gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
0102 }
0103 
0104 static int h3100_irda_startup(struct device *dev)
0105 {
0106     return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
0107 }
0108 
0109 static void h3100_irda_shutdown(struct device *dev)
0110 {
0111     return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
0112 }
0113 
0114 static struct irda_platform_data h3100_irda_data = {
0115     .set_power  = h3100_irda_set_power,
0116     .set_speed  = h3100_irda_set_speed,
0117     .startup    = h3100_irda_startup,
0118     .shutdown   = h3100_irda_shutdown,
0119 };
0120 
0121 static void __init h3100_mach_init(void)
0122 {
0123     h3xxx_mach_init();
0124 
0125     sa11x0_register_pcmcia(-1, NULL);
0126     sa11x0_register_lcd(&h3100_lcd_info);
0127     sa11x0_register_irda(&h3100_irda_data);
0128 }
0129 
0130 MACHINE_START(H3100, "Compaq iPAQ H3100")
0131     .atag_offset    = 0x100,
0132     .map_io     = h3100_map_io,
0133     .nr_irqs    = SA1100_NR_IRQS,
0134     .init_irq   = sa1100_init_irq,
0135     .init_time  = sa1100_timer_init,
0136     .init_machine   = h3100_mach_init,
0137     .init_late  = sa11x0_init_late,
0138     .restart    = sa11x0_restart,
0139 MACHINE_END
0140