18c2ecf20Sopenharmony_ci/*====================================================================== 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci Device driver for the PCMCIA control functionality of StrongARM 48c2ecf20Sopenharmony_ci SA-1100 microprocessors. 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci The contents of this file are subject to the Mozilla Public 78c2ecf20Sopenharmony_ci License Version 1.1 (the "License"); you may not use this file 88c2ecf20Sopenharmony_ci except in compliance with the License. You may obtain a copy of 98c2ecf20Sopenharmony_ci the License at http://www.mozilla.org/MPL/ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci Software distributed under the License is distributed on an "AS 128c2ecf20Sopenharmony_ci IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 138c2ecf20Sopenharmony_ci implied. See the License for the specific language governing 148c2ecf20Sopenharmony_ci rights and limitations under the License. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci The initial developer of the original code is John G. Dorsey 178c2ecf20Sopenharmony_ci <john+@cs.cmu.edu>. Portions created by John G. Dorsey are 188c2ecf20Sopenharmony_ci Copyright (C) 1999 John G. Dorsey. All Rights Reserved. 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci Alternatively, the contents of this file may be used under the 218c2ecf20Sopenharmony_ci terms of the GNU Public License version 2 (the "GPL"), in which 228c2ecf20Sopenharmony_ci case the provisions of the GPL are applicable instead of the 238c2ecf20Sopenharmony_ci above. If you wish to allow the use of your version of this file 248c2ecf20Sopenharmony_ci only under the terms of the GPL and not to allow others to use 258c2ecf20Sopenharmony_ci your version of this file under the MPL, indicate your decision 268c2ecf20Sopenharmony_ci by deleting the provisions above and replace them with the notice 278c2ecf20Sopenharmony_ci and other provisions required by the GPL. If you do not delete 288c2ecf20Sopenharmony_ci the provisions above, a recipient may use your version of this 298c2ecf20Sopenharmony_ci file under either the MPL or the GPL. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci======================================================================*/ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#if !defined(_PCMCIA_SA1100_H) 348c2ecf20Sopenharmony_ci# define _PCMCIA_SA1100_H 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* SA-1100 PCMCIA Memory and I/O timing 378c2ecf20Sopenharmony_ci * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 388c2ecf20Sopenharmony_ci * The SA-1110 Developer's Manual, section 10.2.5, says the following: 398c2ecf20Sopenharmony_ci * 408c2ecf20Sopenharmony_ci * "To calculate the recommended BS_xx value for each address space: 418c2ecf20Sopenharmony_ci * divide the command width time (the greater of twIOWR and twIORD, 428c2ecf20Sopenharmony_ci * or the greater of twWE and twOE) by processor cycle time; divide 438c2ecf20Sopenharmony_ci * by 2; divide again by 3 (number of BCLK's per command assertion); 448c2ecf20Sopenharmony_ci * round up to the next whole number; and subtract 1." 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* MECR: Expansion Memory Configuration Register 488c2ecf20Sopenharmony_ci * (SA-1100 Developers Manual, p.10-13; SA-1110 Developers Manual, p.10-24) 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * MECR layout is: 518c2ecf20Sopenharmony_ci * 528c2ecf20Sopenharmony_ci * FAST1 BSM1<4:0> BSA1<4:0> BSIO1<4:0> FAST0 BSM0<4:0> BSA0<4:0> BSIO0<4:0> 538c2ecf20Sopenharmony_ci * 548c2ecf20Sopenharmony_ci * (This layout is actually true only for the SA-1110; the FASTn bits are 558c2ecf20Sopenharmony_ci * reserved on the SA-1100.) 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define MECR_SOCKET_0_SHIFT (0) 598c2ecf20Sopenharmony_ci#define MECR_SOCKET_1_SHIFT (16) 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci#define MECR_BS_MASK (0x1f) 628c2ecf20Sopenharmony_ci#define MECR_FAST_MODE_MASK (0x01) 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define MECR_BSIO_SHIFT (0) 658c2ecf20Sopenharmony_ci#define MECR_BSA_SHIFT (5) 668c2ecf20Sopenharmony_ci#define MECR_BSM_SHIFT (10) 678c2ecf20Sopenharmony_ci#define MECR_FAST_SHIFT (15) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci#define MECR_SET(mecr, sock, shift, mask, bs) \ 708c2ecf20Sopenharmony_ci((mecr)=((mecr)&~(((mask)<<(shift))<<\ 718c2ecf20Sopenharmony_ci ((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT)))|\ 728c2ecf20Sopenharmony_ci (((bs)<<(shift))<<((sock)==0?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))) 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci#define MECR_GET(mecr, sock, shift, mask) \ 758c2ecf20Sopenharmony_ci((((mecr)>>(((sock)==0)?MECR_SOCKET_0_SHIFT:MECR_SOCKET_1_SHIFT))>>\ 768c2ecf20Sopenharmony_ci (shift))&(mask)) 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#define MECR_BSIO_SET(mecr, sock, bs) \ 798c2ecf20Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK, (bs)) 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define MECR_BSIO_GET(mecr, sock) \ 828c2ecf20Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSIO_SHIFT, MECR_BS_MASK) 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#define MECR_BSA_SET(mecr, sock, bs) \ 858c2ecf20Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK, (bs)) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define MECR_BSA_GET(mecr, sock) \ 888c2ecf20Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSA_SHIFT, MECR_BS_MASK) 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define MECR_BSM_SET(mecr, sock, bs) \ 918c2ecf20Sopenharmony_ciMECR_SET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK, (bs)) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define MECR_BSM_GET(mecr, sock) \ 948c2ecf20Sopenharmony_ciMECR_GET((mecr), (sock), MECR_BSM_SHIFT, MECR_BS_MASK) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define MECR_FAST_SET(mecr, sock, fast) \ 978c2ecf20Sopenharmony_ciMECR_SET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK, (fast)) 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define MECR_FAST_GET(mecr, sock) \ 1008c2ecf20Sopenharmony_ciMECR_GET((mecr), (sock), MECR_FAST_SHIFT, MECR_FAST_MODE_MASK) 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* This function implements the BS value calculation for setting the MECR 1048c2ecf20Sopenharmony_ci * using integer arithmetic: 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_cistatic inline unsigned int sa1100_pcmcia_mecr_bs(unsigned int pcmcia_cycle_ns, 1078c2ecf20Sopenharmony_ci unsigned int cpu_clock_khz){ 1088c2ecf20Sopenharmony_ci unsigned int t = ((pcmcia_cycle_ns * cpu_clock_khz) / 6) - 1000000; 1098c2ecf20Sopenharmony_ci return (t / 1000000) + (((t % 1000000) == 0) ? 0 : 1); 1108c2ecf20Sopenharmony_ci} 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* This function returns the (approximate) command assertion period, in 1138c2ecf20Sopenharmony_ci * nanoseconds, for a given CPU clock frequency and MECR BS value: 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_cistatic inline unsigned int sa1100_pcmcia_cmd_time(unsigned int cpu_clock_khz, 1168c2ecf20Sopenharmony_ci unsigned int pcmcia_mecr_bs){ 1178c2ecf20Sopenharmony_ci return (((10000000 * 2) / cpu_clock_khz) * (3 * (pcmcia_mecr_bs + 1))) / 10; 1188c2ecf20Sopenharmony_ci} 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ciint sa11xx_drv_pcmcia_add_one(struct soc_pcmcia_socket *skt); 1228c2ecf20Sopenharmony_civoid sa11xx_drv_pcmcia_ops(struct pcmcia_low_level *ops); 1238c2ecf20Sopenharmony_ciextern int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops, int first, int nr); 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci#endif /* !defined(_PCMCIA_SA1100_H) */ 126