blob: a6792a0e2726a72784dd8685ccca8782cbe1f3b0 [file] [log] [blame]
Martha Marx44727cb2008-05-29 15:37:21 -04001/*
2 * (C) Copyright 2008
3 * Martha J Marx, Silicon Turnkey Express, mmarx@silicontkx.com
4 * mpc512x I/O pin/pad initialization for the ADS5121 board
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <linux/types.h>
26#include "iopin.h"
27
John Rigby762886c2008-07-11 14:44:09 -060028/* IO pin fields */
29#define IO_PIN_FMUX(v) ((v) << 7) /* pin function */
30#define IO_PIN_HOLD(v) ((v) << 5) /* hold time, pci only */
31#define IO_PIN_PUD(v) ((v) << 4) /* if PUE, 0=pull-down, 1=pull-up */
32#define IO_PIN_PUE(v) ((v) << 3) /* pull up/down enable */
33#define IO_PIN_ST(v) ((v) << 2) /* schmitt trigger */
34#define IO_PIN_DS(v) ((v)) /* slew rate */
Martha Marx44727cb2008-05-29 15:37:21 -040035
36static struct iopin_t {
John Rigby762886c2008-07-11 14:44:09 -060037 int p_offset; /* offset from IOCTL_MEM_OFFSET */
38 int nr_pins; /* number of pins to set this way */
39 int bit_or; /* or in the value instead of overwrite */
40 u_long val; /* value to write or or */
Martha Marx44727cb2008-05-29 15:37:21 -040041} ioregs_init[] = {
John Rigby762886c2008-07-11 14:44:09 -060042 /* FUNC1=FEC_RX_DV Sets Next 3 to FEC pads */
43 {
44 IOCTL_SPDIF_TXCLK, 3, 0,
45 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
46 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
47 },
48 /* Set highest Slew on 9 PATA pins */
49 {
50 IOCTL_PATA_CE1, 9, 1,
51 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
52 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
53 },
54 /* FUNC1=FEC_COL Sets Next 15 to FEC pads */
55 {
56 IOCTL_PSC0_0, 15, 0,
57 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
58 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
59 },
60 /* FUNC1=SPDIF_TXCLK */
61 {
62 IOCTL_LPC_CS1, 1, 0,
63 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
64 IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
65 },
66 /* FUNC2=SPDIF_TX and sets Next pin to SPDIF_RX */
67 {
68 IOCTL_I2C1_SCL, 2, 0,
69 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
70 IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
71 },
72 /* FUNC2=DIU CLK */
73 {
74 IOCTL_PSC6_0, 1, 0,
75 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
76 IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3)
77 },
78 /* FUNC2=DIU_HSYNC */
79 {
80 IOCTL_PSC6_1, 1, 0,
81 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
82 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
83 },
84 /* FUNC2=DIUVSYNC Sets Next 26 to DIU Pads */
85 {
86 IOCTL_PSC6_4, 26, 0,
87 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
88 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
89 }
Martha Marx44727cb2008-05-29 15:37:21 -040090};
91
92void iopin_initialize(void)
93{
94 short i, j, n, p;
95 u_long *reg;
John Rigby762886c2008-07-11 14:44:09 -060096 immap_t *im = (immap_t *)CFG_IMMR;
97
98 reg = (u_long *)&(im->io_ctrl.regs[0]);
Martha Marx44727cb2008-05-29 15:37:21 -040099
100 if (sizeof(ioregs_init) == 0)
101 return;
102
Martha Marx44727cb2008-05-29 15:37:21 -0400103 n = sizeof(ioregs_init) / sizeof(ioregs_init[0]);
104
105 for (i = 0; i < n; i++) {
106 for (p = 0, j = ioregs_init[i].p_offset / sizeof(u_long);
John Rigby762886c2008-07-11 14:44:09 -0600107 p < ioregs_init[i].nr_pins; p++, j++) {
Martha Marx44727cb2008-05-29 15:37:21 -0400108 if (ioregs_init[i].bit_or)
John Rigby762886c2008-07-11 14:44:09 -0600109 reg[j] |= ioregs_init[i].val;
Martha Marx44727cb2008-05-29 15:37:21 -0400110 else
John Rigby762886c2008-07-11 14:44:09 -0600111 reg[j] = ioregs_init[i].val;
Martha Marx44727cb2008-05-29 15:37:21 -0400112 }
113 }
114 return;
115}