2019-06-04 16:11:33 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* linux/drivers/pcmcia/pxa2xx_lubbock.c
|
|
|
|
*
|
|
|
|
* Author: George Davis
|
|
|
|
* Created: Jan 10, 2002
|
|
|
|
* Copyright: MontaVista Software Inc.
|
|
|
|
*
|
|
|
|
* Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
|
|
|
|
*
|
|
|
|
* Lubbock PCMCIA specific routines.
|
|
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/hardware/sa1111.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
|
|
|
#include "sa1111_generic.h"
|
2018-11-28 21:57:23 +08:00
|
|
|
#include "max1600.h"
|
|
|
|
|
|
|
|
static int lubbock_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
|
|
|
|
{
|
|
|
|
struct max1600 *m;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = max1600_init(skt->socket.dev.parent, &m,
|
|
|
|
skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A,
|
|
|
|
MAX1600_CODE_HIGH);
|
|
|
|
if (ret == 0)
|
|
|
|
skt->driver_data = m;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
|
|
|
|
const socket_state_t *state)
|
|
|
|
{
|
2018-11-28 21:57:23 +08:00
|
|
|
struct max1600 *m = skt->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
/* Lubbock uses the Maxim MAX1602, with the following connections:
|
|
|
|
*
|
|
|
|
* Socket 0 (PCMCIA):
|
|
|
|
* MAX1602 Lubbock Register
|
|
|
|
* Pin Signal
|
|
|
|
* ----- ------- ----------------------
|
|
|
|
* A0VPP S0_PWR0 SA-1111 GPIO A<0>
|
|
|
|
* A1VPP S0_PWR1 SA-1111 GPIO A<1>
|
|
|
|
* A0VCC S0_PWR2 SA-1111 GPIO A<2>
|
|
|
|
* A1VCC S0_PWR3 SA-1111 GPIO A<3>
|
|
|
|
* VX VCC
|
|
|
|
* VY +3.3V
|
|
|
|
* 12IN +12V
|
|
|
|
* CODE +3.3V Cirrus Code, CODE = High (VY)
|
|
|
|
*
|
|
|
|
* Socket 1 (CF):
|
|
|
|
* MAX1602 Lubbock Register
|
|
|
|
* Pin Signal
|
|
|
|
* ----- ------- ----------------------
|
|
|
|
* A0VPP GND VPP is not connected
|
|
|
|
* A1VPP GND VPP is not connected
|
|
|
|
* A0VCC S1_PWR0 MISC_WR<14>
|
|
|
|
* A1VCC S1_PWR1 MISC_WR<15>
|
|
|
|
* VX VCC
|
|
|
|
* VY +3.3V
|
|
|
|
* 12IN GND VPP is not connected
|
|
|
|
* CODE +3.3V Cirrus Code, CODE = High (VY)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
again:
|
|
|
|
switch (skt->nr) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
ret = sa1111_pcmcia_configure_socket(skt, state);
|
2018-11-28 21:57:23 +08:00
|
|
|
if (ret == 0)
|
|
|
|
ret = max1600_configure(m, state->Vcc, state->Vpp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#if 1
|
|
|
|
if (ret == 0 && state->Vcc == 33) {
|
|
|
|
struct pcmcia_state new_state;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HACK ALERT:
|
|
|
|
* We can't sense the voltage properly on Lubbock before
|
|
|
|
* actually applying some power to the socket (catch 22).
|
|
|
|
* Resense the socket Voltage Sense pins after applying
|
|
|
|
* socket power.
|
|
|
|
*
|
|
|
|
* Note: It takes about 2.5ms for the MAX1602 VCC output
|
|
|
|
* to rise.
|
|
|
|
*/
|
|
|
|
mdelay(3);
|
|
|
|
|
|
|
|
sa1111_pcmcia_socket_state(skt, &new_state);
|
|
|
|
|
|
|
|
if (!new_state.vs_3v && !new_state.vs_Xv) {
|
|
|
|
/*
|
|
|
|
* Switch to 5V, Configure socket with 5V voltage
|
|
|
|
*/
|
2018-11-28 21:57:23 +08:00
|
|
|
max1600_configure(m, 0, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* It takes about 100ms to turn off Vcc.
|
|
|
|
*/
|
|
|
|
mdelay(100);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to hack around the const qualifier as
|
|
|
|
* well to keep this ugly workaround localized and
|
|
|
|
* not force it to the rest of the code. Barf bags
|
2011-03-31 09:57:33 +08:00
|
|
|
* available in the seat pocket in front of you!
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
((socket_state_t *)state)->Vcc = 50;
|
|
|
|
((socket_state_t *)state)->Vpp = 50;
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pcmcia_low_level lubbock_pcmcia_ops = {
|
|
|
|
.owner = THIS_MODULE,
|
2018-11-28 21:57:23 +08:00
|
|
|
.hw_init = lubbock_pcmcia_hw_init,
|
2005-04-17 06:20:36 +08:00
|
|
|
.configure_socket = lubbock_pcmcia_configure_socket,
|
|
|
|
.first = 0,
|
|
|
|
.nr = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
#include "pxa2xx_base.h"
|
|
|
|
|
2007-12-23 06:03:29 +08:00
|
|
|
int pcmcia_lubbock_init(struct sa1111_dev *sadev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2016-09-02 17:14:20 +08:00
|
|
|
pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
|
pcmcia: lubbock: fix sockets configuration
On lubbock board, the probe of the driver crashes by dereferencing very
early a platform_data structure which is not set, in
pxa2xx_configure_sockets().
The stack fixed is :
[ 0.244353] SA1111 Microprocessor Companion Chip: silicon revision 1, metal revision 1
[ 0.256321] sa1111 sa1111: Providing IRQ336-390
[ 0.340899] clocksource: Switched to clocksource oscr0
[ 0.472263] Unable to handle kernel NULL pointer dereference at virtual address 00000004
[ 0.480469] pgd = c0004000
[ 0.483432] [00000004] *pgd=00000000
[ 0.487105] Internal error: Oops: f5 [#1] ARM
[ 0.491497] Modules linked in:
[ 0.494650] CPU: 0 PID: 1 Comm: swapper Not tainted 4.8.0-rc3-00080-g1aaa68426f0c-dirty #2068
[ 0.503229] Hardware name: Intel DBPXA250 Development Platform (aka Lubbock)
[ 0.510344] task: c3e42000 task.stack: c3e44000
[ 0.514984] PC is at pxa2xx_configure_sockets+0x4/0x24 (drivers/pcmcia/pxa2xx_base.c:227)
[ 0.520193] LR is at pcmcia_lubbock_init+0x1c/0x38
[ 0.525079] pc : [<c0247c30>] lr : [<c02479b0>] psr: a0000053
[ 0.525079] sp : c3e45e70 ip : 100019ff fp : 00000000
[ 0.536651] r10: c0828900 r9 : c0434838 r8 : 00000000
[ 0.541953] r7 : c0820700 r6 : c0857b30 r5 : c3ec1400 r4 : c0820758
[ 0.548549] r3 : 00000000 r2 : 0000000c r1 : c3c09c40 r0 : c3ec1400
[ 0.555154] Flags: NzCv IRQs on FIQs off Mode SVC_32 ISA ARM Segment none
[ 0.562450] Control: 0000397f Table: a0004000 DAC: 00000053
[ 0.568257] Process swapper (pid: 1, stack limit = 0xc3e44190)
[ 0.574154] Stack: (0xc3e45e70 to 0xc3e46000)
[ 0.578610] 5e60: c4849800 00000000 c3ec1400 c024769c
[ 0.586928] 5e80: 00000000 c3ec140c c3c0ee0c c3ec1400 c3ec1434 c020c410 c3ec1400 c3ec1434
[ 0.595244] 5ea0: c0820700 c080b408 c0828900 c020c5f8 00000000 c0820700 c020c578 c020ac5c
[ 0.603560] 5ec0: c3e687cc c3e71e10 c0820700 00000000 c3c02de0 c020bae4 c03c62f7 c03c62f7
[ 0.611872] 5ee0: c3e68780 c0820700 c042e034 00000000 c043c440 c020cdec c080b408 00000005
[ 0.620188] 5f00: c042e034 c00096c0 c0034440 c01c730c 20000053 ffffffff 00000000 00000000
[ 0.628502] 5f20: 00000000 c3ffcb87 c3ffcb90 c00346ac c3e66ba0 c03f7914 00000092 00000005
[ 0.636811] 5f40: 00000005 c03f847c 00000091 c03f847c 00000000 00000005 c0434828 00000005
[ 0.645125] 5f60: c043482c 00000092 c043c440 c0828900 c0434838 c0418d2c 00000005 00000005
[ 0.653430] 5f80: 00000000 c041858c 00000000 c032e9f0 00000000 00000000 00000000 00000000
[ 0.661729] 5fa0: 00000000 c032e9f8 00000000 c000f0f0 00000000 00000000 00000000 00000000
[ 0.670020] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 0.678311] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[ 0.686673] (pxa2xx_configure_sockets) from pcmcia_lubbock_init (/drivers/pcmcia/sa1111_lubbock.c:161)
[ 0.696026] (pcmcia_lubbock_init) from pcmcia_probe (/drivers/pcmcia/sa1111_generic.c:213)
[ 0.704358] (pcmcia_probe) from driver_probe_device (/drivers/base/dd.c:378 /drivers/base/dd.c:499)
[ 0.712848] (driver_probe_device) from __driver_attach (/./include/linux/device.h:983 /drivers/base/dd.c:733)
[ 0.721414] (__driver_attach) from bus_for_each_dev (/drivers/base/bus.c:313)
[ 0.729723] (bus_for_each_dev) from bus_add_driver (/drivers/base/bus.c:708)
[ 0.738036] (bus_add_driver) from driver_register (/drivers/base/driver.c:169)
[ 0.746185] (driver_register) from do_one_initcall (/init/main.c:778)
[ 0.754561] (do_one_initcall) from kernel_init_freeable (/init/main.c:843 /init/main.c:851 /init/main.c:869 /init/main.c:1016)
[ 0.763409] (kernel_init_freeable) from kernel_init (/init/main.c:944)
[ 0.771660] (kernel_init) from ret_from_fork (/arch/arm/kernel/entry-common.S:119)
[ 0.779347] Code: c03c6305 c03c631e c03c632e e5903048 (e993000c)
All code
========
0: c03c6305 eorsgt r6, ip, r5, lsl #6
4: c03c631e eorsgt r6, ip, lr, lsl r3
8: c03c632e eorsgt r6, ip, lr, lsr #6
c: e5903048 ldr r3, [r0, #72] ; 0x48
10:* e993000c ldmib r3, {r2, r3} <-- trapping instruction
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2016-09-01 14:31:08 +08:00
|
|
|
pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops);
|
2016-09-02 17:14:20 +08:00
|
|
|
return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
|
|
|
|
pxa2xx_drv_pcmcia_add_one);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|