1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
23785bc17SMauro Carvalho Chehab /*
33785bc17SMauro Carvalho Chehab * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
43785bc17SMauro Carvalho Chehab * flexcop-sram.c - functions for controlling the SRAM
53785bc17SMauro Carvalho Chehab * see flexcop.c for copyright information
63785bc17SMauro Carvalho Chehab */
73785bc17SMauro Carvalho Chehab #include "flexcop.h"
83785bc17SMauro Carvalho Chehab
flexcop_sram_set_chip(struct flexcop_device * fc,flexcop_sram_type_t type)93785bc17SMauro Carvalho Chehab static void flexcop_sram_set_chip(struct flexcop_device *fc,
103785bc17SMauro Carvalho Chehab flexcop_sram_type_t type)
113785bc17SMauro Carvalho Chehab {
123785bc17SMauro Carvalho Chehab flexcop_set_ibi_value(wan_ctrl_reg_71c, sram_chip, type);
133785bc17SMauro Carvalho Chehab }
143785bc17SMauro Carvalho Chehab
flexcop_sram_init(struct flexcop_device * fc)153785bc17SMauro Carvalho Chehab int flexcop_sram_init(struct flexcop_device *fc)
163785bc17SMauro Carvalho Chehab {
173785bc17SMauro Carvalho Chehab switch (fc->rev) {
183785bc17SMauro Carvalho Chehab case FLEXCOP_II:
193785bc17SMauro Carvalho Chehab case FLEXCOP_IIB:
203785bc17SMauro Carvalho Chehab flexcop_sram_set_chip(fc, FC_SRAM_1_32KB);
213785bc17SMauro Carvalho Chehab break;
223785bc17SMauro Carvalho Chehab case FLEXCOP_III:
233785bc17SMauro Carvalho Chehab flexcop_sram_set_chip(fc, FC_SRAM_1_48KB);
243785bc17SMauro Carvalho Chehab break;
253785bc17SMauro Carvalho Chehab default:
263785bc17SMauro Carvalho Chehab return -EINVAL;
273785bc17SMauro Carvalho Chehab }
283785bc17SMauro Carvalho Chehab return 0;
293785bc17SMauro Carvalho Chehab }
303785bc17SMauro Carvalho Chehab
flexcop_sram_set_dest(struct flexcop_device * fc,flexcop_sram_dest_t dest,flexcop_sram_dest_target_t target)313785bc17SMauro Carvalho Chehab int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest,
323785bc17SMauro Carvalho Chehab flexcop_sram_dest_target_t target)
333785bc17SMauro Carvalho Chehab {
343785bc17SMauro Carvalho Chehab flexcop_ibi_value v;
353785bc17SMauro Carvalho Chehab v = fc->read_ibi_reg(fc, sram_dest_reg_714);
363785bc17SMauro Carvalho Chehab
373785bc17SMauro Carvalho Chehab if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) {
383785bc17SMauro Carvalho Chehab err("SRAM destination target to available on FlexCopII(b)\n");
393785bc17SMauro Carvalho Chehab return -EINVAL;
403785bc17SMauro Carvalho Chehab }
413785bc17SMauro Carvalho Chehab deb_sram("sram dest: %x target: %x\n", dest, target);
423785bc17SMauro Carvalho Chehab
433785bc17SMauro Carvalho Chehab if (dest & FC_SRAM_DEST_NET)
443785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.NET_Dest = target;
453785bc17SMauro Carvalho Chehab if (dest & FC_SRAM_DEST_CAI)
463785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.CAI_Dest = target;
473785bc17SMauro Carvalho Chehab if (dest & FC_SRAM_DEST_CAO)
483785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.CAO_Dest = target;
493785bc17SMauro Carvalho Chehab if (dest & FC_SRAM_DEST_MEDIA)
503785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.MEDIA_Dest = target;
513785bc17SMauro Carvalho Chehab
523785bc17SMauro Carvalho Chehab fc->write_ibi_reg(fc,sram_dest_reg_714,v);
533785bc17SMauro Carvalho Chehab udelay(1000); /* TODO delay really necessary */
543785bc17SMauro Carvalho Chehab
553785bc17SMauro Carvalho Chehab return 0;
563785bc17SMauro Carvalho Chehab }
573785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_sram_set_dest);
583785bc17SMauro Carvalho Chehab
flexcop_wan_set_speed(struct flexcop_device * fc,flexcop_wan_speed_t s)593785bc17SMauro Carvalho Chehab void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s)
603785bc17SMauro Carvalho Chehab {
613785bc17SMauro Carvalho Chehab flexcop_set_ibi_value(wan_ctrl_reg_71c,wan_speed_sig,s);
623785bc17SMauro Carvalho Chehab }
633785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_wan_set_speed);
643785bc17SMauro Carvalho Chehab
flexcop_sram_ctrl(struct flexcop_device * fc,int usb_wan,int sramdma,int maximumfill)653785bc17SMauro Carvalho Chehab void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill)
663785bc17SMauro Carvalho Chehab {
673785bc17SMauro Carvalho Chehab flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714);
683785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.ctrl_usb_wan = usb_wan;
693785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.ctrl_sramdma = sramdma;
703785bc17SMauro Carvalho Chehab v.sram_dest_reg_714.ctrl_maximumfill = maximumfill;
713785bc17SMauro Carvalho Chehab fc->write_ibi_reg(fc,sram_dest_reg_714,v);
723785bc17SMauro Carvalho Chehab }
733785bc17SMauro Carvalho Chehab EXPORT_SYMBOL(flexcop_sram_ctrl);
743785bc17SMauro Carvalho Chehab
753785bc17SMauro Carvalho Chehab #if 0
763785bc17SMauro Carvalho Chehab static void flexcop_sram_write(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
773785bc17SMauro Carvalho Chehab {
783785bc17SMauro Carvalho Chehab int i, retries;
793785bc17SMauro Carvalho Chehab u32 command;
803785bc17SMauro Carvalho Chehab
813785bc17SMauro Carvalho Chehab for (i = 0; i < len; i++) {
823785bc17SMauro Carvalho Chehab command = bank | addr | 0x04000000 | (*buf << 0x10);
833785bc17SMauro Carvalho Chehab
843785bc17SMauro Carvalho Chehab retries = 2;
853785bc17SMauro Carvalho Chehab
863785bc17SMauro Carvalho Chehab while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
873785bc17SMauro Carvalho Chehab mdelay(1);
883785bc17SMauro Carvalho Chehab retries--;
892028c71dSJoe Perches }
903785bc17SMauro Carvalho Chehab
913785bc17SMauro Carvalho Chehab if (retries == 0)
923785bc17SMauro Carvalho Chehab printk("%s: SRAM timeout\n", __func__);
933785bc17SMauro Carvalho Chehab
943785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x700, command);
953785bc17SMauro Carvalho Chehab
963785bc17SMauro Carvalho Chehab buf++;
973785bc17SMauro Carvalho Chehab addr++;
983785bc17SMauro Carvalho Chehab }
993785bc17SMauro Carvalho Chehab }
1003785bc17SMauro Carvalho Chehab
1013785bc17SMauro Carvalho Chehab static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, u32 len)
1023785bc17SMauro Carvalho Chehab {
1033785bc17SMauro Carvalho Chehab int i, retries;
1043785bc17SMauro Carvalho Chehab u32 command, value;
1053785bc17SMauro Carvalho Chehab
1063785bc17SMauro Carvalho Chehab for (i = 0; i < len; i++) {
1073785bc17SMauro Carvalho Chehab command = bank | addr | 0x04008000;
1083785bc17SMauro Carvalho Chehab
1093785bc17SMauro Carvalho Chehab retries = 10000;
1103785bc17SMauro Carvalho Chehab
1113785bc17SMauro Carvalho Chehab while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
1123785bc17SMauro Carvalho Chehab mdelay(1);
1133785bc17SMauro Carvalho Chehab retries--;
1142028c71dSJoe Perches }
1153785bc17SMauro Carvalho Chehab
1163785bc17SMauro Carvalho Chehab if (retries == 0)
1173785bc17SMauro Carvalho Chehab printk("%s: SRAM timeout\n", __func__);
1183785bc17SMauro Carvalho Chehab
1193785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x700, command);
1203785bc17SMauro Carvalho Chehab
1213785bc17SMauro Carvalho Chehab retries = 10000;
1223785bc17SMauro Carvalho Chehab
1233785bc17SMauro Carvalho Chehab while (((read_reg_dw(adapter, 0x700) & 0x80000000) != 0) && (retries > 0)) {
1243785bc17SMauro Carvalho Chehab mdelay(1);
1253785bc17SMauro Carvalho Chehab retries--;
1262028c71dSJoe Perches }
1273785bc17SMauro Carvalho Chehab
1283785bc17SMauro Carvalho Chehab if (retries == 0)
1293785bc17SMauro Carvalho Chehab printk("%s: SRAM timeout\n", __func__);
1303785bc17SMauro Carvalho Chehab
1313785bc17SMauro Carvalho Chehab value = read_reg_dw(adapter, 0x700) >> 0x10;
1323785bc17SMauro Carvalho Chehab
1333785bc17SMauro Carvalho Chehab *buf = (value & 0xff);
1343785bc17SMauro Carvalho Chehab
1353785bc17SMauro Carvalho Chehab addr++;
1363785bc17SMauro Carvalho Chehab buf++;
1373785bc17SMauro Carvalho Chehab }
1383785bc17SMauro Carvalho Chehab }
1393785bc17SMauro Carvalho Chehab
1403785bc17SMauro Carvalho Chehab static void sram_write_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
1413785bc17SMauro Carvalho Chehab {
1423785bc17SMauro Carvalho Chehab u32 bank;
1433785bc17SMauro Carvalho Chehab
1443785bc17SMauro Carvalho Chehab bank = 0;
1453785bc17SMauro Carvalho Chehab
1463785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x20000) {
1473785bc17SMauro Carvalho Chehab bank = (addr & 0x18000) << 0x0d;
1483785bc17SMauro Carvalho Chehab }
1493785bc17SMauro Carvalho Chehab
1503785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x00000) {
1513785bc17SMauro Carvalho Chehab if ((addr >> 0x0f) == 0)
1523785bc17SMauro Carvalho Chehab bank = 0x20000000;
1533785bc17SMauro Carvalho Chehab else
1543785bc17SMauro Carvalho Chehab bank = 0x10000000;
1553785bc17SMauro Carvalho Chehab }
1563785bc17SMauro Carvalho Chehab flex_sram_write(adapter, bank, addr & 0x7fff, buf, len);
1573785bc17SMauro Carvalho Chehab }
1583785bc17SMauro Carvalho Chehab
1593785bc17SMauro Carvalho Chehab static void sram_read_chunk(struct adapter *adapter, u32 addr, u8 *buf, u16 len)
1603785bc17SMauro Carvalho Chehab {
1613785bc17SMauro Carvalho Chehab u32 bank;
1623785bc17SMauro Carvalho Chehab bank = 0;
1633785bc17SMauro Carvalho Chehab
1643785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x20000) {
1653785bc17SMauro Carvalho Chehab bank = (addr & 0x18000) << 0x0d;
1663785bc17SMauro Carvalho Chehab }
1673785bc17SMauro Carvalho Chehab
1683785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x00000) {
1693785bc17SMauro Carvalho Chehab if ((addr >> 0x0f) == 0)
1703785bc17SMauro Carvalho Chehab bank = 0x20000000;
1713785bc17SMauro Carvalho Chehab else
1723785bc17SMauro Carvalho Chehab bank = 0x10000000;
1733785bc17SMauro Carvalho Chehab }
1743785bc17SMauro Carvalho Chehab flex_sram_read(adapter, bank, addr & 0x7fff, buf, len);
1753785bc17SMauro Carvalho Chehab }
1763785bc17SMauro Carvalho Chehab
1773785bc17SMauro Carvalho Chehab static void sram_read(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
1783785bc17SMauro Carvalho Chehab {
1793785bc17SMauro Carvalho Chehab u32 length;
1803785bc17SMauro Carvalho Chehab while (len != 0) {
1813785bc17SMauro Carvalho Chehab length = len;
1823785bc17SMauro Carvalho Chehab /* check if the address range belongs to the same
1833785bc17SMauro Carvalho Chehab * 32K memory chip. If not, the data is read
1843785bc17SMauro Carvalho Chehab * from one chip at a time */
1853785bc17SMauro Carvalho Chehab if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
1863785bc17SMauro Carvalho Chehab length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
1873785bc17SMauro Carvalho Chehab }
1883785bc17SMauro Carvalho Chehab
1893785bc17SMauro Carvalho Chehab sram_read_chunk(adapter, addr, buf, length);
1903785bc17SMauro Carvalho Chehab addr = addr + length;
1913785bc17SMauro Carvalho Chehab buf = buf + length;
1923785bc17SMauro Carvalho Chehab len = len - length;
1933785bc17SMauro Carvalho Chehab }
1943785bc17SMauro Carvalho Chehab }
1953785bc17SMauro Carvalho Chehab
1963785bc17SMauro Carvalho Chehab static void sram_write(struct adapter *adapter, u32 addr, u8 *buf, u32 len)
1973785bc17SMauro Carvalho Chehab {
1983785bc17SMauro Carvalho Chehab u32 length;
1993785bc17SMauro Carvalho Chehab while (len != 0) {
2003785bc17SMauro Carvalho Chehab length = len;
2013785bc17SMauro Carvalho Chehab
2023785bc17SMauro Carvalho Chehab /* check if the address range belongs to the same
2033785bc17SMauro Carvalho Chehab * 32K memory chip. If not, the data is
2043785bc17SMauro Carvalho Chehab * written to one chip at a time */
2053785bc17SMauro Carvalho Chehab if ((addr >> 0x0f) != ((addr + len - 1) >> 0x0f)) {
2063785bc17SMauro Carvalho Chehab length = (((addr >> 0x0f) + 1) << 0x0f) - addr;
2073785bc17SMauro Carvalho Chehab }
2083785bc17SMauro Carvalho Chehab
2093785bc17SMauro Carvalho Chehab sram_write_chunk(adapter, addr, buf, length);
2103785bc17SMauro Carvalho Chehab addr = addr + length;
2113785bc17SMauro Carvalho Chehab buf = buf + length;
2123785bc17SMauro Carvalho Chehab len = len - length;
2133785bc17SMauro Carvalho Chehab }
2143785bc17SMauro Carvalho Chehab }
2153785bc17SMauro Carvalho Chehab
2163785bc17SMauro Carvalho Chehab static void sram_set_size(struct adapter *adapter, u32 mask)
2173785bc17SMauro Carvalho Chehab {
2183785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x71c,
2193785bc17SMauro Carvalho Chehab (mask | (~0x30000 & read_reg_dw(adapter, 0x71c))));
2203785bc17SMauro Carvalho Chehab }
2213785bc17SMauro Carvalho Chehab
2223785bc17SMauro Carvalho Chehab static void sram_init(struct adapter *adapter)
2233785bc17SMauro Carvalho Chehab {
2243785bc17SMauro Carvalho Chehab u32 tmp;
2253785bc17SMauro Carvalho Chehab tmp = read_reg_dw(adapter, 0x71c);
2263785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x71c, 1);
2273785bc17SMauro Carvalho Chehab
2283785bc17SMauro Carvalho Chehab if (read_reg_dw(adapter, 0x71c) != 0) {
2293785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x71c, tmp);
2303785bc17SMauro Carvalho Chehab adapter->dw_sram_type = tmp & 0x30000;
2313785bc17SMauro Carvalho Chehab ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type);
2323785bc17SMauro Carvalho Chehab } else {
2333785bc17SMauro Carvalho Chehab adapter->dw_sram_type = 0x10000;
2343785bc17SMauro Carvalho Chehab ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type);
2353785bc17SMauro Carvalho Chehab }
2363785bc17SMauro Carvalho Chehab }
2373785bc17SMauro Carvalho Chehab
2383785bc17SMauro Carvalho Chehab static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr)
2393785bc17SMauro Carvalho Chehab {
2403785bc17SMauro Carvalho Chehab u8 tmp1, tmp2;
2413785bc17SMauro Carvalho Chehab dprintk("%s: mask = %x, addr = %x\n", __func__, mask, addr);
2423785bc17SMauro Carvalho Chehab
2433785bc17SMauro Carvalho Chehab sram_set_size(adapter, mask);
2443785bc17SMauro Carvalho Chehab sram_init(adapter);
2453785bc17SMauro Carvalho Chehab
2463785bc17SMauro Carvalho Chehab tmp2 = 0xa5;
2473785bc17SMauro Carvalho Chehab tmp1 = 0x4f;
2483785bc17SMauro Carvalho Chehab
2493785bc17SMauro Carvalho Chehab sram_write(adapter, addr, &tmp2, 1);
2503785bc17SMauro Carvalho Chehab sram_write(adapter, addr + 4, &tmp1, 1);
2513785bc17SMauro Carvalho Chehab
2523785bc17SMauro Carvalho Chehab tmp2 = 0;
2533785bc17SMauro Carvalho Chehab mdelay(20);
2543785bc17SMauro Carvalho Chehab
2553785bc17SMauro Carvalho Chehab sram_read(adapter, addr, &tmp2, 1);
2563785bc17SMauro Carvalho Chehab sram_read(adapter, addr, &tmp2, 1);
2573785bc17SMauro Carvalho Chehab
2583785bc17SMauro Carvalho Chehab dprintk("%s: wrote 0xa5, read 0x%2x\n", __func__, tmp2);
2593785bc17SMauro Carvalho Chehab
2603785bc17SMauro Carvalho Chehab if (tmp2 != 0xa5)
2613785bc17SMauro Carvalho Chehab return 0;
2623785bc17SMauro Carvalho Chehab
2633785bc17SMauro Carvalho Chehab tmp2 = 0x5a;
2643785bc17SMauro Carvalho Chehab tmp1 = 0xf4;
2653785bc17SMauro Carvalho Chehab
2663785bc17SMauro Carvalho Chehab sram_write(adapter, addr, &tmp2, 1);
2673785bc17SMauro Carvalho Chehab sram_write(adapter, addr + 4, &tmp1, 1);
2683785bc17SMauro Carvalho Chehab
2693785bc17SMauro Carvalho Chehab tmp2 = 0;
2703785bc17SMauro Carvalho Chehab mdelay(20);
2713785bc17SMauro Carvalho Chehab
2723785bc17SMauro Carvalho Chehab sram_read(adapter, addr, &tmp2, 1);
2733785bc17SMauro Carvalho Chehab sram_read(adapter, addr, &tmp2, 1);
2743785bc17SMauro Carvalho Chehab
2753785bc17SMauro Carvalho Chehab dprintk("%s: wrote 0x5a, read 0x%2x\n", __func__, tmp2);
2763785bc17SMauro Carvalho Chehab
2773785bc17SMauro Carvalho Chehab if (tmp2 != 0x5a)
2783785bc17SMauro Carvalho Chehab return 0;
2793785bc17SMauro Carvalho Chehab return 1;
2803785bc17SMauro Carvalho Chehab }
2813785bc17SMauro Carvalho Chehab
2823785bc17SMauro Carvalho Chehab static u32 sram_length(struct adapter *adapter)
2833785bc17SMauro Carvalho Chehab {
2843785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x10000)
2853785bc17SMauro Carvalho Chehab return 32768; /* 32K */
2863785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x00000)
2873785bc17SMauro Carvalho Chehab return 65536; /* 64K */
2883785bc17SMauro Carvalho Chehab if (adapter->dw_sram_type == 0x20000)
2893785bc17SMauro Carvalho Chehab return 131072; /* 128K */
2903785bc17SMauro Carvalho Chehab return 32768; /* 32K */
2913785bc17SMauro Carvalho Chehab }
2923785bc17SMauro Carvalho Chehab
2933785bc17SMauro Carvalho Chehab /* FlexcopII can work with 32K, 64K or 128K of external SRAM memory.
2943785bc17SMauro Carvalho Chehab - for 128K there are 4x32K chips at bank 0,1,2,3.
2953785bc17SMauro Carvalho Chehab - for 64K there are 2x32K chips at bank 1,2.
2963785bc17SMauro Carvalho Chehab - for 32K there is one 32K chip at bank 0.
2973785bc17SMauro Carvalho Chehab
2983785bc17SMauro Carvalho Chehab FlexCop works only with one bank at a time. The bank is selected
2993785bc17SMauro Carvalho Chehab by bits 28-29 of the 0x700 register.
3003785bc17SMauro Carvalho Chehab
3013785bc17SMauro Carvalho Chehab bank 0 covers addresses 0x00000-0x07fff
3023785bc17SMauro Carvalho Chehab bank 1 covers addresses 0x08000-0x0ffff
3033785bc17SMauro Carvalho Chehab bank 2 covers addresses 0x10000-0x17fff
3043785bc17SMauro Carvalho Chehab bank 3 covers addresses 0x18000-0x1ffff */
3053785bc17SMauro Carvalho Chehab
3063785bc17SMauro Carvalho Chehab static int flexcop_sram_detect(struct flexcop_device *fc)
3073785bc17SMauro Carvalho Chehab {
3083785bc17SMauro Carvalho Chehab flexcop_ibi_value r208, r71c_0, vr71c_1;
3093785bc17SMauro Carvalho Chehab r208 = fc->read_ibi_reg(fc, ctrl_208);
3103785bc17SMauro Carvalho Chehab fc->write_ibi_reg(fc, ctrl_208, ibi_zero);
3113785bc17SMauro Carvalho Chehab
3123785bc17SMauro Carvalho Chehab r71c_0 = fc->read_ibi_reg(fc, wan_ctrl_reg_71c);
3133785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x71c, 1);
3143785bc17SMauro Carvalho Chehab tmp3 = read_reg_dw(adapter, 0x71c);
3153785bc17SMauro Carvalho Chehab dprintk("%s: tmp3 = %x\n", __func__, tmp3);
3163785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x71c, tmp2);
3173785bc17SMauro Carvalho Chehab
3183785bc17SMauro Carvalho Chehab // check for internal SRAM ???
3193785bc17SMauro Carvalho Chehab tmp3--;
3203785bc17SMauro Carvalho Chehab if (tmp3 != 0) {
3213785bc17SMauro Carvalho Chehab sram_set_size(adapter, 0x10000);
3223785bc17SMauro Carvalho Chehab sram_init(adapter);
3233785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x208, tmp);
3243785bc17SMauro Carvalho Chehab dprintk("%s: sram size = 32K\n", __func__);
3253785bc17SMauro Carvalho Chehab return 32;
3263785bc17SMauro Carvalho Chehab }
3273785bc17SMauro Carvalho Chehab
3283785bc17SMauro Carvalho Chehab if (sram_test_location(adapter, 0x20000, 0x18000) != 0) {
3293785bc17SMauro Carvalho Chehab sram_set_size(adapter, 0x20000);
3303785bc17SMauro Carvalho Chehab sram_init(adapter);
3313785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x208, tmp);
3323785bc17SMauro Carvalho Chehab dprintk("%s: sram size = 128K\n", __func__);
3333785bc17SMauro Carvalho Chehab return 128;
3343785bc17SMauro Carvalho Chehab }
3353785bc17SMauro Carvalho Chehab
3363785bc17SMauro Carvalho Chehab if (sram_test_location(adapter, 0x00000, 0x10000) != 0) {
3373785bc17SMauro Carvalho Chehab sram_set_size(adapter, 0x00000);
3383785bc17SMauro Carvalho Chehab sram_init(adapter);
3393785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x208, tmp);
3403785bc17SMauro Carvalho Chehab dprintk("%s: sram size = 64K\n", __func__);
3413785bc17SMauro Carvalho Chehab return 64;
3423785bc17SMauro Carvalho Chehab }
3433785bc17SMauro Carvalho Chehab
3443785bc17SMauro Carvalho Chehab if (sram_test_location(adapter, 0x10000, 0x00000) != 0) {
3453785bc17SMauro Carvalho Chehab sram_set_size(adapter, 0x10000);
3463785bc17SMauro Carvalho Chehab sram_init(adapter);
3473785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x208, tmp);
3483785bc17SMauro Carvalho Chehab dprintk("%s: sram size = 32K\n", __func__);
3493785bc17SMauro Carvalho Chehab return 32;
3503785bc17SMauro Carvalho Chehab }
3513785bc17SMauro Carvalho Chehab
3523785bc17SMauro Carvalho Chehab sram_set_size(adapter, 0x10000);
3533785bc17SMauro Carvalho Chehab sram_init(adapter);
3543785bc17SMauro Carvalho Chehab write_reg_dw(adapter, 0x208, tmp);
3553785bc17SMauro Carvalho Chehab dprintk("%s: SRAM detection failed. Set to 32K \n", __func__);
3563785bc17SMauro Carvalho Chehab return 0;
3573785bc17SMauro Carvalho Chehab }
3583785bc17SMauro Carvalho Chehab
3593785bc17SMauro Carvalho Chehab static void sll_detect_sram_size(struct adapter *adapter)
3603785bc17SMauro Carvalho Chehab {
3613785bc17SMauro Carvalho Chehab sram_detect_for_flex2(adapter);
3623785bc17SMauro Carvalho Chehab }
3633785bc17SMauro Carvalho Chehab
3643785bc17SMauro Carvalho Chehab #endif
365