/***************************************************************************
* Copyright (C) 2007-2008 by unsik Kim <donari75@gmail.com> *
* *
* 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; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "mflash.h"
#include "time_support.h"
#include "fileio.h"
#include "log.h"
static int s3c2440_set_gpio_to_output (mflash_gpio_num_t gpio);
static int s3c2440_set_gpio_output_val (mflash_gpio_num_t gpio, uint8_t val);
static int pxa270_set_gpio_to_output (mflash_gpio_num_t gpio);
static int pxa270_set_gpio_output_val (mflash_gpio_num_t gpio, uint8_t val);
static command_t *mflash_cmd;
static mflash_bank_t *mflash_bank;
static mflash_gpio_drv_t pxa270_gpio = {
.name = "pxa270",
.set_gpio_to_output = pxa270_set_gpio_to_output,
.set_gpio_output_val = pxa270_set_gpio_output_val
};
static mflash_gpio_drv_t s3c2440_gpio = {
.name = "s3c2440",
.set_gpio_to_output = s3c2440_set_gpio_to_output,
.set_gpio_output_val = s3c2440_set_gpio_output_val
};
static mflash_gpio_drv_t *mflash_gpio[] =
{
&pxa270_gpio,
&s3c2440_gpio,
NULL
};
#define PXA270_GAFR0_L 0x40E00054
#define PXA270_GAFR3_U 0x40E00070
#define PXA270_GAFR3_U_RESERVED_BITS 0xfffc0000u
#define PXA270_GPDR0 0x40E0000C
#define PXA270_GPDR3 0x40E0010C
#define PXA270_GPDR3_RESERVED_BITS 0xfe000000u
#define PXA270_GPSR0 0x40E00018
#define PXA270_GPCR0 0x40E00024
static int pxa270_set_gpio_to_output (mflash_gpio_num_t gpio)
{
uint32_t addr, value, mask;
target_t *target = mflash_bank->target;
int ret;
/* remove alternate function. */
mask = 0x3u << (gpio.num & 0xF)*2;
addr = PXA270_GAFR0_L + (gpio.num >> 4) * 4;
if ((ret = target_read_u32(target, addr, &value)) != ERROR_OK)
return ret;
value &= ~mask;
if (addr == PXA270_GAFR3_U)