diff options
author | Ondrej Zary <linux@rainbow-software.org> | 2015-02-06 17:11:41 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Odin.com> | 2015-04-09 21:08:05 -0400 |
commit | f71429ab535d90806a35bc346adcdebfc8996008 (patch) | |
tree | 05d055ec1ab6ec55e9ba3a8b25fe97d641d60a71 | |
parent | 3a70c006edbe6071bd78e1e0c8004791cd4b531c (diff) |
aha1542: rework configuration parameters
Remove __setup and introduce separate io, bus_on, bus_off and dma_speed
module parameters.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: James Bottomley <JBottomley@Odin.com>
-rw-r--r-- | drivers/scsi/aha1542.c | 213 |
1 files changed, 54 insertions, 159 deletions
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 8c915d721ce0..d15191324b06 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
@@ -53,56 +53,30 @@ | |||
53 | #else | 53 | #else |
54 | #define DEB(x) | 54 | #define DEB(x) |
55 | #endif | 55 | #endif |
56 | #define MAXBOARDS 4 | ||
56 | 57 | ||
57 | /* | 58 | static bool isapnp = 1; |
58 | static const char RCSid[] = "$Header: /usr/src/linux/kernel/blk_drv/scsi/RCS/aha1542.c,v 1.1 1992/07/24 06:27:38 root Exp root $"; | 59 | module_param(isapnp, bool, 0); |
59 | */ | 60 | MODULE_PARM_DESC(isapnp, "enable PnP support (default=1)"); |
60 | |||
61 | /* The adaptec can be configured for quite a number of addresses, but | ||
62 | I generally do not want the card poking around at random. We allow | ||
63 | two addresses - this allows people to use the Adaptec with a Midi | ||
64 | card, which also used 0x330 -- can be overridden with LILO! */ | ||
65 | |||
66 | #define MAXBOARDS 4 /* Increase this and the sizes of the | ||
67 | arrays below, if you need more.. */ | ||
68 | |||
69 | /* Boards 3,4 slots are reserved for ISAPnP scans */ | ||
70 | |||
71 | static unsigned int bases[MAXBOARDS] = {0x330, 0x334, 0, 0}; | ||
72 | 61 | ||
73 | /* set by aha1542_setup according to the command line; they also may | 62 | static int io[MAXBOARDS] = { 0x330, 0x334, 0, 0 }; |
74 | be marked __initdata, but require zero initializers then */ | 63 | module_param_array(io, int, NULL, 0); |
64 | MODULE_PARM_DESC(io, "base IO address of controller (0x130,0x134,0x230,0x234,0x330,0x334, default=0x330,0x334)"); | ||
75 | 65 | ||
76 | static int setup_called[MAXBOARDS]; | 66 | /* time AHA spends on the AT-bus during data transfer */ |
77 | static int setup_buson[MAXBOARDS]; | 67 | static int bus_on[MAXBOARDS] = { -1, -1, -1, -1 }; /* power-on default: 11us */ |
78 | static int setup_busoff[MAXBOARDS]; | 68 | module_param_array(bus_on, int, NULL, 0); |
79 | static int setup_dmaspeed[MAXBOARDS] = { -1, -1, -1, -1 }; | 69 | MODULE_PARM_DESC(bus_on, "bus on time [us] (2-15, default=-1 [HW default: 11])"); |
80 | 70 | ||
81 | /* | 71 | /* time AHA spends off the bus (not to monopolize it) during data transfer */ |
82 | * LILO/Module params: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]] | 72 | static int bus_off[MAXBOARDS] = { -1, -1, -1, -1 }; /* power-on default: 4us */ |
83 | * | 73 | module_param_array(bus_off, int, NULL, 0); |
84 | * Where: <PORTBASE> is any of the valid AHA addresses: | 74 | MODULE_PARM_DESC(bus_off, "bus off time [us] (1-64, default=-1 [HW default: 4])"); |
85 | * 0x130, 0x134, 0x230, 0x234, 0x330, 0x334 | ||
86 | * <BUSON> is the time (in microsecs) that AHA spends on the AT-bus | ||
87 | * when transferring data. 1542A power-on default is 11us, | ||
88 | * valid values are in range: 2..15 (decimal) | ||
89 | * <BUSOFF> is the time that AHA spends OFF THE BUS after while | ||
90 | * it is transferring data (not to monopolize the bus). | ||
91 | * Power-on default is 4us, valid range: 1..64 microseconds. | ||
92 | * <DMASPEED> Default is jumper selected (1542A: on the J1), | ||
93 | * but experimenter can alter it with this. | ||
94 | * Valid values: 5, 6, 7, 8, 10 (MB/s) | ||
95 | * Factory default is 5 MB/s. | ||
96 | */ | ||
97 | 75 | ||
98 | #if defined(MODULE) | 76 | /* default is jumper selected (J1 on 1542A), factory default = 5 MB/s */ |
99 | static bool isapnp = 0; | 77 | static int dma_speed[MAXBOARDS] = { -1, -1, -1, -1 }; |
100 | static int aha1542[] = {0x330, 11, 4, -1}; | 78 | module_param_array(dma_speed, int, NULL, 0); |
101 | module_param_array(aha1542, int, NULL, 0); | 79 | MODULE_PARM_DESC(dma_speed, "DMA speed [MB/s] (5,6,7,8,10, default=-1 [by jumper])"); |
102 | module_param(isapnp, bool, 0); | ||
103 | #else | ||
104 | static int isapnp = 1; | ||
105 | #endif | ||
106 | 80 | ||
107 | #define BIOS_TRANSLATION_1632 0 /* Used by some old 1542A boards */ | 81 | #define BIOS_TRANSLATION_1632 0 /* Used by some old 1542A boards */ |
108 | #define BIOS_TRANSLATION_6432 1 /* Default case these days */ | 82 | #define BIOS_TRANSLATION_6432 1 /* Default case these days */ |
@@ -792,101 +766,48 @@ static int aha1542_query(int base_io, int *transl) | |||
792 | return 0; | 766 | return 0; |
793 | } | 767 | } |
794 | 768 | ||
795 | #ifndef MODULE | 769 | static u8 dma_speed_hw(int dma_speed) |
796 | static char *setup_str[MAXBOARDS] __initdata; | ||
797 | static int setup_idx = 0; | ||
798 | |||
799 | static void __init aha1542_setup(char *str, int *ints) | ||
800 | { | 770 | { |
801 | const char *ahausage = "aha1542: usage: aha1542=<PORTBASE>[,<BUSON>,<BUSOFF>[,<DMASPEED>]]\n"; | 771 | switch (dma_speed) { |
802 | int setup_portbase; | 772 | case 5: |
803 | 773 | return 0x00; | |
804 | if (setup_idx >= MAXBOARDS) { | 774 | case 6: |
805 | printk(KERN_ERR "aha1542: aha1542_setup called too many times! Bad LILO params ?\n"); | 775 | return 0x04; |
806 | printk(KERN_ERR " Entryline 1: %s\n", setup_str[0]); | 776 | case 7: |
807 | printk(KERN_ERR " Entryline 2: %s\n", setup_str[1]); | 777 | return 0x01; |
808 | printk(KERN_ERR " This line: %s\n", str); | 778 | case 8: |
809 | return; | 779 | return 0x02; |
810 | } | 780 | case 10: |
811 | if (ints[0] < 1 || ints[0] > 4) { | 781 | return 0x03; |
812 | printk(KERN_ERR "aha1542: %s\n", str); | ||
813 | printk(ahausage); | ||
814 | printk(KERN_ERR "aha1542: Wrong parameters may cause system malfunction.. We try anyway..\n"); | ||
815 | } | ||
816 | setup_called[setup_idx] = ints[0]; | ||
817 | setup_str[setup_idx] = str; | ||
818 | |||
819 | setup_portbase = ints[0] >= 1 ? ints[1] : 0; /* Preserve the default value.. */ | ||
820 | setup_buson[setup_idx] = ints[0] >= 2 ? ints[2] : 7; | ||
821 | setup_busoff[setup_idx] = ints[0] >= 3 ? ints[3] : 5; | ||
822 | if (ints[0] >= 4) | ||
823 | { | ||
824 | int atbt = -1; | ||
825 | switch (ints[4]) { | ||
826 | case 5: | ||
827 | atbt = 0x00; | ||
828 | break; | ||
829 | case 6: | ||
830 | atbt = 0x04; | ||
831 | break; | ||
832 | case 7: | ||
833 | atbt = 0x01; | ||
834 | break; | ||
835 | case 8: | ||
836 | atbt = 0x02; | ||
837 | break; | ||
838 | case 10: | ||
839 | atbt = 0x03; | ||
840 | break; | ||
841 | default: | ||
842 | printk(KERN_ERR "aha1542: %s\n", str); | ||
843 | printk(ahausage); | ||
844 | printk(KERN_ERR "aha1542: Valid values for DMASPEED are 5-8, 10 MB/s. Using jumper defaults.\n"); | ||
845 | break; | ||
846 | } | ||
847 | setup_dmaspeed[setup_idx] = atbt; | ||
848 | } | 782 | } |
849 | if (setup_portbase != 0) | ||
850 | bases[setup_idx] = setup_portbase; | ||
851 | 783 | ||
852 | ++setup_idx; | 784 | return 0xff; /* invalid */ |
853 | } | 785 | } |
854 | 786 | ||
855 | static int __init do_setup(char *str) | 787 | /* Set the Bus on/off-times as not to ruin floppy performance */ |
788 | static void aha1542_set_bus_times(int indx) | ||
856 | { | 789 | { |
857 | int ints[5]; | 790 | unsigned int base_io = io[indx]; |
858 | 791 | ||
859 | int count=setup_idx; | 792 | if (bus_on[indx] > 0) { |
793 | u8 oncmd[] = { CMD_BUSON_TIME, clamp(bus_on[indx], 2, 15) }; | ||
860 | 794 | ||
861 | get_options(str, ARRAY_SIZE(ints), ints); | 795 | aha1542_intr_reset(base_io); |
862 | aha1542_setup(str,ints); | 796 | if (aha1542_out(base_io, oncmd, 2)) |
797 | goto fail; | ||
798 | } | ||
863 | 799 | ||
864 | return count<setup_idx; | 800 | if (bus_off[indx] > 0) { |
865 | } | 801 | u8 offcmd[] = { CMD_BUSOFF_TIME, clamp(bus_off[indx], 1, 64) }; |
866 | 802 | ||
867 | __setup("aha1542=",do_setup); | 803 | aha1542_intr_reset(base_io); |
868 | #endif | 804 | if (aha1542_out(base_io, offcmd, 2)) |
805 | goto fail; | ||
806 | } | ||
869 | 807 | ||
870 | /* Set the Bus on/off-times as not to ruin floppy performance */ | 808 | if (dma_speed_hw(dma_speed[indx]) != 0xff) { |
871 | static void aha1542_set_bus_times(int indx) | 809 | u8 dmacmd[] = { CMD_DMASPEED, dma_speed_hw(dma_speed[indx]) }; |
872 | { | ||
873 | unsigned int base_io = bases[indx]; | ||
874 | u8 oncmd[] = {CMD_BUSON_TIME, 7}; | ||
875 | u8 offcmd[] = {CMD_BUSOFF_TIME, 5}; | ||
876 | 810 | ||
877 | if (setup_called[indx]) { | ||
878 | oncmd[1] = setup_buson[indx]; | ||
879 | offcmd[1] = setup_busoff[indx]; | ||
880 | } | ||
881 | aha1542_intr_reset(base_io); | ||
882 | if (aha1542_out(base_io, oncmd, 2)) | ||
883 | goto fail; | ||
884 | aha1542_intr_reset(base_io); | ||
885 | if (aha1542_out(base_io, offcmd, 2)) | ||
886 | goto fail; | ||
887 | if (setup_dmaspeed[indx] >= 0) { | ||
888 | u8 dmacmd[] = {CMD_DMASPEED, 0}; | ||
889 | dmacmd[1] = setup_dmaspeed[indx]; | ||
890 | aha1542_intr_reset(base_io); | 811 | aha1542_intr_reset(base_io); |
891 | if (aha1542_out(base_io, dmacmd, 2)) | 812 | if (aha1542_out(base_io, dmacmd, 2)) |
892 | goto fail; | 813 | goto fail; |
@@ -901,7 +822,7 @@ fail: | |||
901 | /* return non-zero on detection */ | 822 | /* return non-zero on detection */ |
902 | static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) | 823 | static struct Scsi_Host *aha1542_hw_init(struct scsi_host_template *tpnt, struct device *pdev, int indx) |
903 | { | 824 | { |
904 | unsigned int base_io = bases[indx]; | 825 | unsigned int base_io = io[indx]; |
905 | struct Scsi_Host *shpnt; | 826 | struct Scsi_Host *shpnt; |
906 | struct aha1542_hostdata *aha1542; | 827 | struct aha1542_hostdata *aha1542; |
907 | 828 | ||
@@ -1207,19 +1128,19 @@ static int aha1542_pnp_probe(struct pnp_dev *pdev, const struct pnp_device_id *i | |||
1207 | int indx; | 1128 | int indx; |
1208 | struct Scsi_Host *sh; | 1129 | struct Scsi_Host *sh; |
1209 | 1130 | ||
1210 | for (indx = 0; indx < ARRAY_SIZE(bases); indx++) { | 1131 | for (indx = 0; indx < ARRAY_SIZE(io); indx++) { |
1211 | if (bases[indx]) | 1132 | if (io[indx]) |
1212 | continue; | 1133 | continue; |
1213 | 1134 | ||
1214 | if (pnp_activate_dev(pdev) < 0) | 1135 | if (pnp_activate_dev(pdev) < 0) |
1215 | continue; | 1136 | continue; |
1216 | 1137 | ||
1217 | bases[indx] = pnp_port_start(pdev, 0); | 1138 | io[indx] = pnp_port_start(pdev, 0); |
1218 | 1139 | ||
1219 | /* The card can be queried for its DMA, we have | 1140 | /* The card can be queried for its DMA, we have |
1220 | the DMA set up that is enough */ | 1141 | the DMA set up that is enough */ |
1221 | 1142 | ||
1222 | printk(KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n", bases[indx]); | 1143 | printk(KERN_INFO "ISAPnP found an AHA1535 at I/O 0x%03X\n", io[indx]); |
1223 | } | 1144 | } |
1224 | 1145 | ||
1225 | sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); | 1146 | sh = aha1542_hw_init(&driver_template, &pdev->dev, indx); |
@@ -1248,32 +1169,6 @@ static int pnp_registered; | |||
1248 | static int __init aha1542_init(void) | 1169 | static int __init aha1542_init(void) |
1249 | { | 1170 | { |
1250 | int ret = 0; | 1171 | int ret = 0; |
1251 | #ifdef MODULE | ||
1252 | int atbt = -1; | ||
1253 | |||
1254 | bases[0] = aha1542[0]; | ||
1255 | setup_buson[0] = aha1542[1]; | ||
1256 | setup_busoff[0] = aha1542[2]; | ||
1257 | |||
1258 | switch (aha1542[3]) { | ||
1259 | case 5: | ||
1260 | atbt = 0x00; | ||
1261 | break; | ||
1262 | case 6: | ||
1263 | atbt = 0x04; | ||
1264 | break; | ||
1265 | case 7: | ||
1266 | atbt = 0x01; | ||
1267 | break; | ||
1268 | case 8: | ||
1269 | atbt = 0x02; | ||
1270 | break; | ||
1271 | case 10: | ||
1272 | atbt = 0x03; | ||
1273 | break; | ||
1274 | }; | ||
1275 | setup_dmaspeed[0] = atbt; | ||
1276 | #endif | ||
1277 | 1172 | ||
1278 | #ifdef CONFIG_PNP | 1173 | #ifdef CONFIG_PNP |
1279 | if (isapnp) { | 1174 | if (isapnp) { |