/* 2009-08-18: File added and changed by Sony Corporation */
/*
 *  LCD Support for PGPF
 *
 *  Copyright 2009 Sony Corporation.
 *
 *  This program is free software; you can redistribute  it and/or modify it
 *  under  the terms of  the GNU General  Public License as published by the
 *  Free Software Foundation;  version 2 of the  License.
 *
 *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED
 *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF
 *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
 *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF
 *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *  You should have received a copy of the  GNU General Public License along
 *  with this program; if not, write  to the Free Software Foundation, Inc.,
 *  675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#ifndef _PGPF_LCDHW_H_
#define _PGPF_LCDHW_H_

#include <linux/fb.h>
#include <asm/arch/smu.h>
#include <asm/arch/pgpf/blhw.h>

/* SMU divider definition */
/* Note that duty is not 50% */
#ifndef SMU_DIV26
#define SMU_DIV26 0xc1
#endif
#ifndef SMU_DIV30
#define SMU_DIV30 0xe1
#endif
#ifndef SMU_DIV36
#define SMU_DIV36 0x82
#endif
#ifndef SMU_DIV44
#define SMU_DIV44 0xa2
#endif

#define CHG_PINSEL_G48_LCD_BIT  (0xFFFFFFF0)
#define CHG_PINSEL_G48_LCD_INIT (0x55555550)
#define CHG_PINSEL_G64_LCD_BIT  (0x0000FFFF)
#define CHG_PINSEL_G64_LCD_INIT (0x00005555)

struct pgpf_lcdhw_config {
	/* for fb_var_screeninfo */
	unsigned int xres;
	unsigned int yres;
    __u32 pixclock;

	/* for SMU */
	unsigned int divlcdlclk;

	/* for LCDC */
	unsigned int control;
	unsigned int htotal;
	unsigned int harea;
	unsigned int hedge1;
	unsigned int hedge2;
	unsigned int vtotal;
	unsigned int varea;
	unsigned int vedge1;
	unsigned int vedge2;
};	

enum PGPF_LCD_STATUS {
	PGPF_LCD_STATUS_INIT = -1,
	PGPF_LCD_STATUS_OFF = 0,
	PGPF_LCD_STATUS_ON = 1,
};

struct pgpf_lcdhw_device {
	/* functions */
	int (*init)(struct pgpf_bl_device* bl_dev);
	void (*exit)(struct pgpf_bl_device* bl_dev);
	int (*suspend)(int save, struct pgpf_bl_device* bl_dev);
	int (*resume)(int restore, struct pgpf_bl_device* bl_dev);

	/* configuration */
	struct pgpf_lcdhw_config config;
	int status;
};

int pgpf_lcdhw_init(void);
int pgpf_lcdhw_exit(void);
int pgpf_lcdhw_suspend(int save);
int pgpf_lcdhw_resume(int resotre);
int pgpf_lcdhw_register(struct pgpf_lcdhw_device** lcd_dev, struct platform_device* pf_dev);
int pgpf_lcdhw_unregister(void);

int pgpf_lcdhw_get_status(void);
int pgpf_lcdhw_change_gio_settings(int lcdmode);
int pgpf_lcdhw_setup_clock(void);
int pgpf_lcdhw_controller_hw_init(void);
int pgpf_lcdhw_set_vscreeninfo(struct fb_var_screeninfo* vinfo);

void pgpf_set_lcd_pon(int flag);
void pgpf_set_lcd_pwron(int flag);
#endif /* _PGPF_LCDHW_H_ */
