3 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
26 #include <asm/arch/ssi.h>
27 #include <asm/arch/sc520.h>
29 int ssi_set_interface(int freq, int lsb_first, int inv_clock, int inv_phase)
34 temp |= CTL_CLK_SEL_4;
35 else if (freq >= 4096)
36 temp |= CTL_CLK_SEL_8;
37 else if (freq >= 2048)
38 temp |= CTL_CLK_SEL_16;
39 else if (freq >= 1024)
40 temp |= CTL_CLK_SEL_32;
42 temp |= CTL_CLK_SEL_64;
44 temp |= CTL_CLK_SEL_128;
46 temp |= CTL_CLK_SEL_256;
48 temp |= CTL_CLK_SEL_512;
59 writeb(temp, &sc520_mmcr->ssictl);
64 u8 ssi_txrx_byte(u8 data)
66 writeb(data, &sc520_mmcr->ssixmit);
67 while (readb(&sc520_mmcr->ssista) & SSISTA_BSY)
69 writeb(SSICMD_CMD_SEL_XMITRCV, &sc520_mmcr->ssicmd);
70 while (readb(&sc520_mmcr->ssista) & SSISTA_BSY)
73 return readb(&sc520_mmcr->ssircv);
76 void ssi_tx_byte(u8 data)
78 writeb(data, &sc520_mmcr->ssixmit);
79 while (readb(&sc520_mmcr->ssista) & SSISTA_BSY)
81 writeb(SSICMD_CMD_SEL_XMIT, &sc520_mmcr->ssicmd);
86 while (readb(&sc520_mmcr->ssista) & SSISTA_BSY)
88 writeb(SSICMD_CMD_SEL_RCV, &sc520_mmcr->ssicmd);
89 while (readb(&sc520_mmcr->ssista) & SSISTA_BSY)
92 return readb(&sc520_mmcr->ssircv);