18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Hardware parameter area specific to Sharp SL series devices
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2005 Richard Purdie
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Based on Sharp's 2.4 kernel patches
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/kernel.h>
118c2ecf20Sopenharmony_ci#include <linux/module.h>
128c2ecf20Sopenharmony_ci#include <linux/string.h>
138c2ecf20Sopenharmony_ci#include <asm/mach/sharpsl_param.h>
148c2ecf20Sopenharmony_ci#include <asm/memory.h>
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci/*
178c2ecf20Sopenharmony_ci * Certain hardware parameters determined at the time of device manufacture,
188c2ecf20Sopenharmony_ci * typically including LCD parameters are loaded by the bootloader at the
198c2ecf20Sopenharmony_ci * address PARAM_BASE. As the kernel will overwrite them, we need to store
208c2ecf20Sopenharmony_ci * them early in the boot process, then pass them to the appropriate drivers.
218c2ecf20Sopenharmony_ci * Not all devices use all parameters but the format is common to all.
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_SA1100
248c2ecf20Sopenharmony_ci#define PARAM_BASE	0xe8ffc000
258c2ecf20Sopenharmony_ci#define param_start(x)	(void *)(x)
268c2ecf20Sopenharmony_ci#else
278c2ecf20Sopenharmony_ci#define PARAM_BASE	0xa0000a00
288c2ecf20Sopenharmony_ci#define param_start(x)	__va(x)
298c2ecf20Sopenharmony_ci#endif
308c2ecf20Sopenharmony_ci#define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 )  | ( b << 8 ) | a )
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define COMADJ_MAGIC	MAGIC_CHG('C','M','A','D')
338c2ecf20Sopenharmony_ci#define UUID_MAGIC	MAGIC_CHG('U','U','I','D')
348c2ecf20Sopenharmony_ci#define TOUCH_MAGIC	MAGIC_CHG('T','U','C','H')
358c2ecf20Sopenharmony_ci#define AD_MAGIC	MAGIC_CHG('B','V','A','D')
368c2ecf20Sopenharmony_ci#define PHAD_MAGIC	MAGIC_CHG('P','H','A','D')
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_cistruct sharpsl_param_info sharpsl_param;
398c2ecf20Sopenharmony_ciEXPORT_SYMBOL(sharpsl_param);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_civoid sharpsl_save_param(void)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info));
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	if (sharpsl_param.comadj_keyword != COMADJ_MAGIC)
468c2ecf20Sopenharmony_ci		sharpsl_param.comadj=-1;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	if (sharpsl_param.phad_keyword != PHAD_MAGIC)
498c2ecf20Sopenharmony_ci		sharpsl_param.phadadj=-1;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	if (sharpsl_param.uuid_keyword != UUID_MAGIC)
528c2ecf20Sopenharmony_ci		sharpsl_param.uuid[0]=-1;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	if (sharpsl_param.touch_keyword != TOUCH_MAGIC)
558c2ecf20Sopenharmony_ci		sharpsl_param.touch_xp=-1;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	if (sharpsl_param.adadj_keyword != AD_MAGIC)
588c2ecf20Sopenharmony_ci		sharpsl_param.adadj=-1;
598c2ecf20Sopenharmony_ci}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci
62