Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] SPI: spi_butterfly, restore lost deltas

This resolves some minor version skew glitches that accumulated for the AVR
Butterfly adapter driver, which caused among other things the existence of
a duplicate Kconfig entry. Most of it boils down to comment updates, but in
one case it removes some now-superfluous code that would be better if not
copied into other controller-level drivers.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

authored by

David Brownell and committed by
Greg Kroah-Hartman
9c1da3cb 022f7b07

+34 -35
+17 -6
Documentation/spi/butterfly
··· 12 12 directly to the Butterfly. Or (if you have the parts and skills) you 13 13 can come up with something fancier, providing ciruit protection to the 14 14 Butterfly and the printer port, or with a better power supply than two 15 - signal pins from the printer port. 15 + signal pins from the printer port. Or for that matter, you can use 16 + similar cables to talk to many AVR boards, even a breadboard. 17 + 18 + This is more powerful than "ISP programming" cables since it lets kernel 19 + SPI protocol drivers interact with the AVR, and could even let the AVR 20 + issue interrupts to them. Later, your protocol driver should work 21 + easily with a "real SPI controller", instead of this bitbanger. 16 22 17 23 18 24 The first cable connections will hook Linux up to one SPI bus, with the 19 25 AVR and a DataFlash chip; and to the AVR reset line. This is all you 20 26 need to reflash the firmware, and the pins are the standard Atmel "ISP" 21 - connector pins (used also on non-Butterfly AVR boards). 27 + connector pins (used also on non-Butterfly AVR boards). On the parport 28 + side this is like "sp12" programming cables. 22 29 23 30 Signal Butterfly Parport (DB-25) 24 31 ------ --------- --------------- ··· 47 40 SELECT = J400.PB0/nSS = pin 17/C3,nSELECT 48 41 GND = J400.GND = pin 24/GND 49 42 50 - The "USI" controller, using J405, can be used for a second SPI bus. That 51 - would let you talk to the AVR over SPI, running firmware that makes it act 52 - as an SPI slave, while letting either Linux or the AVR use the DataFlash. 53 - There are plenty of spare parport pins to wire this one up, such as: 43 + Or you could flash firmware making the AVR into an SPI slave (keeping the 44 + DataFlash in reset) and tweak the spi_butterfly driver to make it bind to 45 + the driver for your custom SPI-based protocol. 46 + 47 + The "USI" controller, using J405, can also be used for a second SPI bus. 48 + That would let you talk to the AVR using custom SPI-with-USI firmware, 49 + while letting either Linux or the AVR use the DataFlash. There are plenty 50 + of spare parport pins to wire this one up, such as: 54 51 55 52 Signal Butterfly Parport (DB-25) 56 53 ------ --------- ---------------
-10
drivers/spi/Kconfig
··· 75 75 inexpensive battery powered microcontroller evaluation board. 76 76 This same cable can be used to flash new firmware. 77 77 78 - config SPI_BUTTERFLY 79 - tristate "Parallel port adapter for AVR Butterfly (DEVELOPMENT)" 80 - depends on SPI_MASTER && PARPORT && EXPERIMENTAL 81 - select SPI_BITBANG 82 - help 83 - This uses a custom parallel port cable to connect to an AVR 84 - Butterfly <http://www.atmel.com/products/avr/butterfly>, an 85 - inexpensive battery powered microcontroller evaluation board. 86 - This same cable can be used to flash new firmware. 87 - 88 78 # 89 79 # Add new SPI master controllers in alphabetical order above this line 90 80 #
+17 -19
drivers/spi/spi_butterfly.c
··· 163 163 struct butterfly *pp = spidev_to_pp(spi); 164 164 165 165 /* set default clock polarity */ 166 - if (value) 166 + if (value != BITBANG_CS_INACTIVE) 167 167 setsck(spi, spi->mode & SPI_CPOL); 168 168 169 169 /* no chipselect on this USI link config */ 170 170 if (is_usidev(spi)) 171 171 return; 172 172 173 - /* here, value == "activate or not" */ 174 - 175 - /* most PARPORT_CONTROL_* bits are negated */ 173 + /* here, value == "activate or not"; 174 + * most PARPORT_CONTROL_* bits are negated, so we must 175 + * morph it to value == "bit value to write in control register" 176 + */ 176 177 if (spi_cs_bit == PARPORT_CONTROL_INIT) 177 178 value = !value; 178 - 179 - /* here, value == "bit value to write in control register" */ 180 179 181 180 parport_frob_control(pp->port, spi_cs_bit, value ? spi_cs_bit : 0); 182 181 } ··· 201 202 202 203 /* override default partitioning with cmdlinepart */ 203 204 static struct mtd_partition partitions[] = { { 204 - /* JFFS2 wants partitions of 4*N blocks for this device ... */ 205 + /* JFFS2 wants partitions of 4*N blocks for this device, 206 + * so sectors 0 and 1 can't be partitions by themselves. 207 + */ 205 208 206 209 /* sector 0 = 8 pages * 264 bytes/page (1 block) 207 210 * sector 1 = 248 pages * 264 bytes/page ··· 317 316 if (status < 0) 318 317 goto clean2; 319 318 320 - /* Bus 1 lets us talk to at45db041b (firmware disables AVR) 321 - * or AVR (firmware resets at45, acts as spi slave) 319 + /* Bus 1 lets us talk to at45db041b (firmware disables AVR SPI), AVR 320 + * (firmware resets at45, acts as spi slave) or neither (we ignore 321 + * both, AVR uses AT45). Here we expect firmware for the first option. 322 322 */ 323 323 pp->info[0].max_speed_hz = 15 * 1000 * 1000; 324 324 strcpy(pp->info[0].modalias, "mtd_dataflash"); ··· 332 330 pp->dataflash->dev.bus_id); 333 331 334 332 #ifdef HAVE_USI 335 - /* even more custom AVR firmware */ 333 + /* Bus 2 is only for talking to the AVR, and it can work no 334 + * matter who masters bus 1; needs appropriate AVR firmware. 335 + */ 336 336 pp->info[1].max_speed_hz = 10 /* ?? */ * 1000 * 1000; 337 337 strcpy(pp->info[1].modalias, "butterfly"); 338 338 // pp->info[1].platform_data = ... TBD ... ; ··· 382 378 pp = butterfly; 383 379 butterfly = NULL; 384 380 385 - #ifdef HAVE_USI 386 - spi_unregister_device(pp->butterfly); 387 - pp->butterfly = NULL; 388 - #endif 389 - spi_unregister_device(pp->dataflash); 390 - pp->dataflash = NULL; 391 - 381 + /* stop() unregisters child devices too */ 382 + pdev = to_platform_device(pp->bitbang.master->cdev.dev); 392 383 status = spi_bitbang_stop(&pp->bitbang); 393 384 394 385 /* turn off VCC */ ··· 392 393 393 394 parport_release(pp->pd); 394 395 parport_unregister_device(pp->pd); 395 - 396 - pdev = to_platform_device(pp->bitbang.master->cdev.dev); 397 396 398 397 (void) spi_master_put(pp->bitbang.master); 399 398 ··· 417 420 } 418 421 module_exit(butterfly_exit); 419 422 423 + MODULE_DESCRIPTION("Parport Adapter driver for AVR Butterfly"); 420 424 MODULE_LICENSE("GPL");