Commit f54fe87acedbbad7d29ad18cab31d2b323717514

Authored by Kumar Gala
1 parent 54648985e2

85xx/fsl-sata: Use is_serdes_configured() to determine if SATA is enabled

On the MPC85xx platform if we have SATA its connected on SERDES.
Determing if SATA is enabled via sata_initialize should not be board
specific and thus we move it out of the MPC8536DS board code.

Additionally, now that we have is_serdes_configured() we can determine
if the given SATA port is enabled and error out if its not in the
driver.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Showing 3 changed files with 26 additions and 13 deletions Side-by-side Diff

arch/powerpc/cpu/mpc85xx/cpu_init.c
1 1 /*
2   - * Copyright 2007-2009 Freescale Semiconductor, Inc.
  2 + * Copyright 2007-2010 Freescale Semiconductor, Inc.
3 3 *
4 4 * (C) Copyright 2003 Motorola Inc.
5 5 * Modified by Xianghua Xiao, X.Xiao@motorola.com
6 6  
... ... @@ -30,9 +30,11 @@
30 30 #include <watchdog.h>
31 31 #include <asm/processor.h>
32 32 #include <ioports.h>
  33 +#include <sata.h>
33 34 #include <asm/io.h>
34 35 #include <asm/mmu.h>
35 36 #include <asm/fsl_law.h>
  37 +#include <asm/fsl_serdes.h>
36 38 #include "mp.h"
37 39  
38 40 DECLARE_GLOBAL_DATA_PTR;
... ... @@ -418,4 +420,14 @@
418 420  
419 421 setup_ivors();
420 422 }
  423 +
  424 +#if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA)
  425 +int sata_initialize(void)
  426 +{
  427 + if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2))
  428 + return __sata_initialize();
  429 +
  430 + return 1;
  431 +}
  432 +#endif
board/freescale/mpc8536ds/mpc8536ds.c
... ... @@ -498,17 +498,6 @@
498 498 }
499 499 #endif
500 500  
501   -int sata_initialize(void)
502   -{
503   - volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
504   - uint sdrs2_io_sel =
505   - (gur->pordevsr & MPC85xx_PORDEVSR_SRDS2_IO_SEL) >> 27;
506   - if (sdrs2_io_sel & 0x04)
507   - return 1;
508   -
509   - return __sata_initialize();
510   -}
511   -
512 501 int board_eth_init(bd_t *bis)
513 502 {
514 503 #ifdef CONFIG_TSEC_ENET
drivers/block/fsl_sata.c
1 1 /*
2   - * Copyright (C) 2008 Freescale Semiconductor, Inc.
  2 + * Copyright (C) 2008,2010 Freescale Semiconductor, Inc.
3 3 * Dave Liu <daveliu@freescale.com>
4 4 *
5 5 * This program is free software; you can redistribute it and/or
... ... @@ -22,6 +22,7 @@
22 22 #include <command.h>
23 23 #include <asm/io.h>
24 24 #include <asm/processor.h>
  25 +#include <asm/fsl_serdes.h>
25 26 #include <malloc.h>
26 27 #include <libata.h>
27 28 #include <fis.h>
... ... @@ -128,6 +129,17 @@
128 129 printf("the sata index %d is out of ranges\n\r", dev);
129 130 return -1;
130 131 }
  132 +
  133 +#ifdef CONFIG_MPC85xx
  134 + if ((dev == 0) && (!is_serdes_configured(SATA1))) {
  135 + printf("SATA%d [dev = %d] is not enabled\n", dev+1, dev);
  136 + return -1;
  137 + }
  138 + if ((dev == 1) && (!is_serdes_configured(SATA2))) {
  139 + printf("SATA%d [dev = %d] is not enabled\n", dev+1, dev);
  140 + return -1;
  141 + }
  142 +#endif
131 143  
132 144 /* Allocate SATA device driver struct */
133 145 sata = (fsl_sata_t *)malloc(sizeof(fsl_sata_t));