162306a36Sopenharmony_ci/*====================================================================== 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci Device driver for the PCMCIA control functionality of StrongARM 462306a36Sopenharmony_ci SA-1100 microprocessors. 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci The contents of this file are subject to the Mozilla Public 762306a36Sopenharmony_ci License Version 1.1 (the "License"); you may not use this file 862306a36Sopenharmony_ci except in compliance with the License. You may obtain a copy of 962306a36Sopenharmony_ci the License at http://www.mozilla.org/MPL/ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci Software distributed under the License is distributed on an "AS 1262306a36Sopenharmony_ci IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 1362306a36Sopenharmony_ci implied. See the License for the specific language governing 1462306a36Sopenharmony_ci rights and limitations under the License. 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci The initial developer of the original code is John G. Dorsey 1762306a36Sopenharmony_ci <john+@cs.cmu.edu>. Portions created by John G. Dorsey are 1862306a36Sopenharmony_ci Copyright (C) 1999 John G. Dorsey. All Rights Reserved. 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci Alternatively, the contents of this file may be used under the 2162306a36Sopenharmony_ci terms of the GNU Public License version 2 (the "GPL"), in which 2262306a36Sopenharmony_ci case the provisions of the GPL are applicable instead of the 2362306a36Sopenharmony_ci above. If you wish to allow the use of your version of this file 2462306a36Sopenharmony_ci only under the terms of the GPL and not to allow others to use 2562306a36Sopenharmony_ci your version of this file under the MPL, indicate your decision 2662306a36Sopenharmony_ci by deleting the provisions above and replace them with the notice 2762306a36Sopenharmony_ci and other provisions required by the GPL. If you do not delete 2862306a36Sopenharmony_ci the provisions above, a recipient may use your version of this 2962306a36Sopenharmony_ci file under either the MPL or the GPL. 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci======================================================================*/ 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci#if !defined(_PCMCIA_SA1100_H) 3462306a36Sopenharmony_ci# define _PCMCIA_SA1100_H 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* SA-1100 PCMCIA Memory and I/O timing 3762306a36Sopenharmony_ci * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3862306a36Sopenharmony_ci * The SA-1110 Developer's Manual, section 10.2.5, says the following: 3962306a36Sopenharmony_ci * 4062306a36Sopenharmony_ci * "To calculate the recommended BS_xx value for each address space: 4162306a36Sopenharmony_ci * divide the command width time (the greater of twIOWR and twIORD, 4262306a36Sopenharmony_ci * or the greater of twWE and twOE) by processor cycle time; divide 4362306a36Sopenharmony_ci * by 2; divide again by 3 (number of BCLK's per command assertion); 4462306a36Sopenharmony_ci * round up to the next whole number; and subtract 1." 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci/* MECR: Expansion Memory Configuration Register 4862306a36Sopenharmony_ci * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24) 4962306a36Sopenharmony_ci * 5062306a36Sopenharmony_ci * MECR layout is: 5162306a36Sopenharmony_ci * 5262306a36Sopenharmony_ci * FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0> 5362306a36Sopenharmony_ci * 5462306a36Sopenharmony_ci * (This layout is actually true only for the SA-1110; the FASTn bits are 5562306a36Sopenharmony_ci * reserved on the SA-1100.) 5662306a36Sopenharmony_ci */ 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#define MECR_SOCKET_0_SHIFT (0) 5962306a36Sopenharmony_ci#define MECR_SOCKET_1_SHIFT (16) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#define MECR_BS_MASK (0x1f) 6262306a36Sopenharmony_ci#define MECR_FAST_MODE_MASK (0x01) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#define MECR_BSIO_SHIFT (0) 6562306a36Sopenharmony_ci#define MECR_BSA_SHIFT (5) 6662306a36Sopenharmony_ci#define MECR_BSM_SHIFT (10) 6762306a36Sopenharmony_ci#define MECR_FAST_SHIFT (15) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define MECR_SET(mecr, sock, shift, mask, bs) \ 7062306a36Sopenharmony_ci((mecr)=((mecr)&~(((mask)<<(shift))<<\ 7162306a36Sopenharmony_ci ((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))|\ 7262306a36Sopenharmony_ci (((bs)<<(shift))<<((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))) 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#define MECR_GET(mecr, sock, shift, mask) \ 7562306a36Sopenharmony_ci((((mecr)>>(((sock)==0)?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))>>\ 7662306a36Sopenharmony_ci (shift))&(mask)) 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci#define MECR_BSIO_SET(mecr, sock, bs) \ 7962306a36Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK, (bs)) 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci#define MECR_BSIO_GET(mecr, sock) \ 8262306a36Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci#define MECR_BSA_SET(mecr, sock, bs) \ 8562306a36Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK, (bs)) 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci#define MECR_BSA_GET(mecr, sock) \ 8862306a36Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK) 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci#define MECR_BSM_SET(mecr, sock, bs) \ 9162306a36Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK, (bs)) 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ci#define MECR_BSM_GET(mecr, sock) \ 9462306a36Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci#define MECR_FAST_SET(mecr, sock, fast) \ 9762306a36Sopenharmony_ciMECR_SET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK, (fast)) 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ci#define MECR_FAST_GET(mecr, sock) \ 10062306a36Sopenharmony_ciMECR_GET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK) 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* This function implements the BS value calculation for setting the MECR 10462306a36Sopenharmony_ci * using integer arithmetic: 10562306a36Sopenharmony_ci */ 10662306a36Sopenharmony_cistatic inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns, 10762306a36Sopenharmony_ci unsigned int cpu_clock_khz){ 10862306a36Sopenharmony_ci unsigned int t = ((pcmcia_cycle_ns * cpu_clock_khz) / 6) - 1000000; 10962306a36Sopenharmony_ci return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1); 11062306a36Sopenharmony_ci} 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci/* This function returns the (approximate) command assertion period, in 11362306a36Sopenharmony_ci * nanoseconds, for a given CPU clock frequency and MECR BS value: 11462306a36Sopenharmony_ci */ 11562306a36Sopenharmony_cistatic inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz, 11662306a36Sopenharmony_ci unsigned int pcmcia_mecr_bs){ 11762306a36Sopenharmony_ci return (((10000000 * 2) / cpu_clock_khz) * (3 * (pcmcia_mecr_bs + 1))) / 10; 11862306a36Sopenharmony_ci} 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ciint sa11xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt); 12262306a36Sopenharmony_civoid sa11xx_drv_pcmcia_ops(struct pcmcia_low_level *ops); 12362306a36Sopenharmony_ciextern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci#endif /* !defined(_PCMCIA_SA1100_H) */ 126