kernel-fxtec-pro1x/drivers/spi
Ernst Schwab 4f4517c45f spi: Correct SPI clock frequency setting in spi_mpc8xxx
Correct SPI clock frequency division factor rounding, preventing clock rates
higher than the maximum specified clock frequency being used.

When specifying spi-max-frequency = <10000000> in the device tree,
the resulting frequency was 11.1 MHz, with spibrg being 133333332.

According to the freescale data sheet [1], the spi clock rate is
spiclk = spibrg / (4 * (pm+1))

The existing code calculated
  pm = mpc8xxx_spi->spibrg / (hz * 4); pm--;
  resulting in pm = (int) (3.3333) - 1 = 2,
  resulting in spiclk = 133333332/(4*(2+1)) = 11111111

  With the fix,
   pm = (mpc8xxx_spi->spibrg - 1) / (hz * 4) + 1; pm--;
   resulting in pm = (int) (4.3333) - 1 = 3,
   resulting in spiclk = 133333332/(4*(3+1)) = 8333333

   Without the fix, for every desired SPI frequency that
   is not exactly derivable from spibrg, pm will be too
   small due to rounding down, resulting in a too high SPI clock,
   so we need a pm which is one higher.

   For values that are exactly derivable, spibrg will
   be dividable by (hz*4) without remainder, and
   (int) ((spibrg-1)/(hz*4)) will be one lower than
   (int) (spibrg)/(hz*4), which is compensated by adding 1.
   For these values, the fixed version calculates the same pm
   as the unfixed version.

   For all values that are not exactly derivable,
   spibrg will be not dividable by (hz*4) without
   remainder, and (int) ((spibrg-1)/(hz*4)) will be
   the same as (int) (spibrg)/(hz*4), and the calculated pm will
   be one higher than calculated by the unfixed version.

References:
[1] http://www.freescale.com/files/32bit/doc/ref_manual/MPC8315ERM.pdf,
   page 22-10 -> 1398

Signed-off-by: Ernst Schwab <eschwab@online.de>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-02-16 14:26:58 -07:00
..
amba-pl022.c ARM: 5741/1: pl022: fix peripheral id for ST vendor 2009-10-05 17:55:55 +01:00
atmel_spi.c spi: atmel_spi.c: use resource_size() 2009-12-17 08:59:06 -07:00
atmel_spi.h
au1550_spi.c spi/au1550_spi: fix setupxfer not to override cfg with zeros 2009-12-08 18:48:16 -07:00
coldfire_qspi.c spi: Add Freescale/Motorola Coldfire QSPI driver 2010-01-20 13:49:44 -07:00
davinci_spi.c spi: Add SPI master driver for DaVinci/DA8xx 2010-01-20 13:49:34 -07:00
dw_spi.c spi/dw_spi: fix missing export of dw_spi_remove_host 2010-01-21 07:25:38 -07:00
dw_spi_mmio.c spi/dw_spi: mmio code style fixups 2010-01-21 09:55:42 -07:00
dw_spi_pci.c spi/dw_spi: refine the IRQ mode working flow 2010-01-20 13:49:45 -07:00
Kconfig spi/dw_spi: Fix dw_spi_mmio to depend on HAVE_CLK 2010-01-22 10:08:31 -07:00
Makefile Memory-mapped dw_spi driver 2010-01-21 07:46:42 -07:00
mpc52xx_psc_spi.c spi: make Open Firmware device id constant 2010-01-20 13:49:44 -07:00
mpc52xx_spi.c spi: make Open Firmware device id constant 2010-01-20 13:49:44 -07:00
omap2_mcspi.c omap: headers: Move remaining headers from include/mach to include/plat 2009-10-20 09:40:47 -07:00
omap_spi_100k.c Add OMAP spi100k driver 2009-12-13 01:02:11 -07:00
omap_uwire.c omap: headers: Move remaining headers from include/mach to include/plat 2009-10-20 09:40:47 -07:00
orion_spi.c spi: move more spi_setup() functionality into core 2009-06-18 13:03:42 -07:00
pxa2xx_spi.c const: constify remaining dev_pm_ops 2009-12-15 08:53:25 -08:00
spi.c spi: handle TX-only/RX-only 2009-09-23 07:39:44 -07:00
spi_bfin5xx.c spi: spi_bfin5xx.c: use resource_size() 2009-12-17 08:59:50 -07:00
spi_bitbang.c spi: bitbang bugfix in message setup 2009-06-30 18:56:00 -07:00
spi_butterfly.c spi: struct device - replace bus_id with dev_name(), dev_set_name() 2009-01-06 10:44:37 -08:00
spi_gpio.c spi-gpio: allow operation without CS signal 2009-04-02 19:04:51 -07:00
spi_imx.c spi/spi_imx: add device information by switching pr_debug() to dev_dbg() 2010-01-20 13:49:45 -07:00
spi_lm70llp.c hwmon: (lm70) Code streamlining and cleanup 2009-01-07 16:37:34 +01:00
spi_mpc8xxx.c spi: Correct SPI clock frequency setting in spi_mpc8xxx 2010-02-16 14:26:58 -07:00
spi_nuc900.c ARM: NUC900: Add spi driver support for nuc900 2009-12-13 00:58:00 -07:00
spi_ppc4xx.c spi: make Open Firmware device id constant 2010-01-20 13:49:44 -07:00
spi_s3c24xx.c Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6 2009-12-17 15:59:05 -08:00
spi_s3c24xx_fiq.h spi_s3c24xx: add FIQ pseudo-DMA support 2009-12-17 08:57:01 -07:00
spi_s3c24xx_fiq.S spi_s3c24xx: add FIQ pseudo-DMA support 2009-12-17 08:57:01 -07:00
spi_s3c24xx_gpio.c [ARM] S3C24XX: GPIO: Move gpio functions out of <mach/hardware.h> 2009-05-18 16:25:40 +01:00
spi_s3c64xx.c spi/spi_s3c64xx.c: Fix continuation line formats 2010-02-02 01:07:07 -07:00
spi_sh_msiof.c spi: update MSIOF includes 2010-01-20 13:49:45 -07:00
spi_sh_sci.c spi: spi_sh_sci.c: use resource_size() 2009-12-17 09:00:10 -07:00
spi_stmp.c spi: Fix reversed args to time_before() in Freescale stmp driver. 2010-01-20 13:49:44 -07:00
spi_txx9.c Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6 2009-12-17 15:59:05 -08:00
spidev.c Merge branch 'next-spi' of git://git.secretlab.ca/git/linux-2.6 2009-12-17 15:59:05 -08:00
tle62x0.c spi: prefix modalias with "spi:" 2009-09-23 07:39:43 -07:00
xilinx_spi.c spi: xilinx_spi: Fix up I/O routine wrapping bogosity. 2010-01-20 13:49:45 -07:00
xilinx_spi.h xilinx_spi: Split into of driver and generic part. 2009-12-08 18:48:14 -07:00
xilinx_spi_of.c spi: make Open Firmware device id constant 2010-01-20 13:49:44 -07:00
xilinx_spi_pltfm.c xilinx_spi: add a platform driver using the xilinx_spi common module. 2009-12-08 18:48:14 -07:00