Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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