* MA 02111-1307 USA
*/
+/*
+ * WARNING:
+ *
+ * As the code is right now, it expects all PIO ports A,B,C,...
+ * to be evenly spaced in the memory map:
+ * ATMEL_BASE_PIOA + port * sizeof at91pio_t
+ * This might not necessaryly be true in future Atmel SoCs.
+ * This code should be fixed to use a pointer array to the ports.
+ */
+
#include <config.h>
#include <common.h>
#include <asm/sizes.h>
int at91_set_pio_pullup(unsigned port, unsigned pin, int use_pullup)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
if (use_pullup)
writel(1 << pin, &pio->port[port].puer);
*/
int at91_set_pio_periph(unsigned port, unsigned pin, int use_pullup)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
*/
int at91_set_a_periph(unsigned port, unsigned pin, int use_pullup)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
*/
int at91_set_b_periph(unsigned port, unsigned pin, int use_pullup)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
*/
int at91_set_pio_input(unsigned port, u32 pin, int use_pullup)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
at91_set_pio_pullup(port, pin, use_pullup);
*/
int at91_set_pio_output(unsigned port, u32 pin, int value)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
writel(mask, &pio->port[port].idr);
writel(mask, &pio->port[port].pudr);
*/
int at91_set_pio_deglitch(unsigned port, unsigned pin, int is_on)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
if (is_on)
writel(mask, &pio->port[port].ifer);
*/
int at91_set_pio_multi_drive(unsigned port, unsigned pin, int is_on)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
if (is_on)
writel(mask, &pio->port[port].mder);
*/
int at91_set_pio_value(unsigned port, unsigned pin, int value)
{
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
if (value)
writel(mask, &pio->port[port].sodr);
*/
int at91_get_pio_value(unsigned port, unsigned pin)
{
- u32 pdsr = 0;
- at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+ u32 pdsr = 0;
+ at91_pio_t *pio = (at91_pio_t *) ATMEL_BASE_PIOA;
u32 mask;
- if ((port < AT91_PIO_PORTS) && (pin < 32)) {
+ if ((port < ATMEL_PIO_PORTS) && (pin < 32)) {
mask = 1 << pin;
pdsr = readl(&pio->port[port].pdsr) & mask;
}
int rtc_get (struct rtc_time *tmp)
{
- at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
- at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+ at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+ at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
ulong tim;
ulong tim2;
ulong off;
int rtc_set (struct rtc_time *tmp)
{
- at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
- at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+ at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+ at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
ulong tim;
tim = mktime (tmp->tm_year, tmp->tm_mon, tmp->tm_mday,
void rtc_reset (void)
{
- at91_rtt_t *rtt = (at91_rtt_t *) AT91_RTT_BASE;
- at91_gpbr_t *gpbr = (at91_gpbr_t *) AT91_GPR_BASE;
+ at91_rtt_t *rtt = (at91_rtt_t *) ATMEL_BASE_RTT;
+ at91_gpbr_t *gpbr = (at91_gpbr_t *) ATMEL_BASE_GPBR;
/* clear alarm, set prescaler to 32768, clear counter */
writel(32768+AT91_RTT_RTTRST, &rtt->mr);
int usb_cpu_init(void)
{
- at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
+ at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
#endif
/* Enable USB host clock. */
- writel(1 << AT91_ID_UHP, &pmc->pcer);
+ writel(1 << ATMEL_ID_UHP, &pmc->pcer);
#ifdef CONFIG_AT91SAM9261
- writel(AT91_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
+ writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scer);
#else
- writel(AT91_PMC_UHP, &pmc->scer);
+ writel(ATMEL_PMC_UHP, &pmc->scer);
#endif
return 0;
int usb_cpu_stop(void)
{
- at91_pmc_t *pmc = (at91_pmc_t *)AT91_PMC_BASE;
+ at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
/* Disable USB host clock. */
- writel(1 << AT91_ID_UHP, &pmc->pcdr);
+ writel(1 << ATMEL_ID_UHP, &pmc->pcdr);
#ifdef CONFIG_AT91SAM9261
- writel(AT91_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
+ writel(ATMEL_PMC_UHP | AT91_PMC_HCK0, &pmc->scdr);
#else
- writel(AT91_PMC_UHP, &pmc->scdr);
+ writel(ATMEL_PMC_UHP, &pmc->scdr);
#endif
#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \