Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * PISMO memory driver - http://www.pismoworld.org/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * For ARM Realview and Versatile platforms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/mtd/physmap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/mtd/plat-ram.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/mtd/pismo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define PISMO_NUM_CS	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) struct pismo_cs_block {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	u8	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	u8	width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	__le16	access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	__le32	size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	u32	reserved[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	char	device[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct pismo_eeprom {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct pismo_cs_block cs[PISMO_NUM_CS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	char	board[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u8	sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) struct pismo_mem {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	phys_addr_t base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	u32	size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	u16	access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u8	width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u8	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) struct pismo_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct i2c_client	*client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	void			(*vpp)(void *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	void			*vpp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	struct platform_device	*dev[PISMO_NUM_CS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) static void pismo_set_vpp(struct platform_device *pdev, int on)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	struct i2c_client *client = to_i2c_client(pdev->dev.parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	struct pismo_data *pismo = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	pismo->vpp(pismo->vpp_data, on);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static unsigned int pismo_width_to_bytes(unsigned int width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	width &= 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	if (width > 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return 1 << width;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static int pismo_eeprom_read(struct i2c_client *client, void *buf, u8 addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 			     size_t size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct i2c_msg msg[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			.addr = client->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 			.len = sizeof(addr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			.buf = &addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		}, {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			.addr = client->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			.flags = I2C_M_RD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			.len = size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 			.buf = buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	ret = i2c_transfer(client->adapter, msg, ARRAY_SIZE(msg));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	return ret == ARRAY_SIZE(msg) ? size : -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static int pismo_add_device(struct pismo_data *pismo, int i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 			    struct pismo_mem *region, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			    void *pdata, size_t psize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct platform_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	struct resource res = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	phys_addr_t base = region->base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (base == ~0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return -ENXIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	res.start = base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	res.end = base + region->size - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	res.flags = IORESOURCE_MEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	dev = platform_device_alloc(name, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (!dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	dev->dev.parent = &pismo->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		ret = platform_device_add_resources(dev, &res, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 		ret = platform_device_add_data(dev, pdata, psize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		ret = platform_device_add(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		pismo->dev[i] = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	} while (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	platform_device_put(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int pismo_add_nor(struct pismo_data *pismo, int i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			 struct pismo_mem *region)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	struct physmap_flash_data data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		.width = region->width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (pismo->vpp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		data.set_vpp = pismo_set_vpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	return pismo_add_device(pismo, i, region, "physmap-flash",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		&data, sizeof(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static int pismo_add_sram(struct pismo_data *pismo, int i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			  struct pismo_mem *region)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct platdata_mtd_ram data = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		.bankwidth = region->width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	return pismo_add_device(pismo, i, region, "mtd-ram",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		&data, sizeof(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) static void pismo_add_one(struct pismo_data *pismo, int i,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 			  const struct pismo_cs_block *cs, phys_addr_t base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct device *dev = &pismo->client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct pismo_mem region;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	region.base = base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	region.type = cs->type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	region.width = pismo_width_to_bytes(cs->width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	region.access = le16_to_cpu(cs->access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	region.size = le32_to_cpu(cs->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (region.width == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		dev_err(dev, "cs%u: bad width: %02x, ignoring\n", i, cs->width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	 * FIXME: may need to the platforms memory controller here, but at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	 * the moment we assume that it has already been correctly setup.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	 * The memory controller can also tell us the base address as well.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	dev_info(dev, "cs%u: %.32s: type %02x access %u00ps size %uK\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		i, cs->device, region.type, region.access, region.size / 1024);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	switch (region.type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	case 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		/* static DOC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		/* static NOR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		pismo_add_nor(pismo, i, &region);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		/* static RAM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		pismo_add_sram(pismo, i, &region);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static int pismo_remove(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	struct pismo_data *pismo = i2c_get_clientdata(client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	for (i = 0; i < ARRAY_SIZE(pismo->dev); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		platform_device_unregister(pismo->dev[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	kfree(pismo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static int pismo_probe(struct i2c_client *client,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		       const struct i2c_device_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	struct pismo_pdata *pdata = client->dev.platform_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	struct pismo_eeprom eeprom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	struct pismo_data *pismo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	int ret, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		dev_err(&client->dev, "functionality mismatch\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	pismo = kzalloc(sizeof(*pismo), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (!pismo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	pismo->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	if (pdata) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		pismo->vpp = pdata->set_vpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		pismo->vpp_data = pdata->vpp_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	i2c_set_clientdata(client, pismo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	ret = pismo_eeprom_read(client, &eeprom, 0, sizeof(eeprom));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		dev_err(&client->dev, "error reading EEPROM: %d\n", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		goto exit_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	dev_info(&client->dev, "%.15s board found\n", eeprom.board);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	for (i = 0; i < ARRAY_SIZE(eeprom.cs); i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		if (eeprom.cs[i].type != 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			pismo_add_one(pismo, i, &eeprom.cs[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 				      pdata->cs_addrs[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)  exit_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	kfree(pismo);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static const struct i2c_device_id pismo_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	{ "pismo" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	{ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MODULE_DEVICE_TABLE(i2c, pismo_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static struct i2c_driver pismo_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	.driver	= {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		.name	= "pismo",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	.probe		= pismo_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	.remove		= pismo_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	.id_table	= pismo_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static int __init pismo_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	BUILD_BUG_ON(sizeof(struct pismo_cs_block) != 48);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	BUILD_BUG_ON(sizeof(struct pismo_eeprom) != 256);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	return i2c_add_driver(&pismo_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) module_init(pismo_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static void __exit pismo_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	i2c_del_driver(&pismo_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) module_exit(pismo_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) MODULE_AUTHOR("Russell King <linux@arm.linux.org.uk>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) MODULE_DESCRIPTION("PISMO memory driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) MODULE_LICENSE("GPL");