12e192b24SSimon Glass /* 22e192b24SSimon Glass * Copyright (C) 2000-2005, DENX Software Engineering 32e192b24SSimon Glass * Wolfgang Denk <wd@denx.de> 42e192b24SSimon Glass * Copyright (C) Procsys. All rights reserved. 52e192b24SSimon Glass * Mushtaq Khan <mushtaq_k@procsys.com> 62e192b24SSimon Glass * <mushtaqk_921@yahoo.co.in> 72e192b24SSimon Glass * Copyright (C) 2008 Freescale Semiconductor, Inc. 82e192b24SSimon Glass * Dave Liu <daveliu@freescale.com> 92e192b24SSimon Glass * 102e192b24SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 112e192b24SSimon Glass */ 122e192b24SSimon Glass 132e192b24SSimon Glass #include <common.h> 142e192b24SSimon Glass #include <command.h> 152e192b24SSimon Glass #include <part.h> 162e192b24SSimon Glass #include <sata.h> 172e192b24SSimon Glass 182e192b24SSimon Glass static int sata_curr_device = -1; 192e192b24SSimon Glass 202e192b24SSimon Glass static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 212e192b24SSimon Glass { 222e192b24SSimon Glass int rc = 0; 232e192b24SSimon Glass 242e192b24SSimon Glass if (argc == 2 && strcmp(argv[1], "stop") == 0) 252e192b24SSimon Glass return sata_stop(); 262e192b24SSimon Glass 272e192b24SSimon Glass if (argc == 2 && strcmp(argv[1], "init") == 0) { 282e192b24SSimon Glass if (sata_curr_device != -1) 292e192b24SSimon Glass sata_stop(); 302e192b24SSimon Glass 318547f45bSGary Bisson return (sata_initialize() < 0) ? 328547f45bSGary Bisson CMD_RET_FAILURE : CMD_RET_SUCCESS; 332e192b24SSimon Glass } 342e192b24SSimon Glass 352e192b24SSimon Glass /* If the user has not yet run `sata init`, do it now */ 36aa6ab905STang Yuantian if (sata_curr_device == -1) { 37aa6ab905STang Yuantian rc = sata_initialize(); 38aa6ab905STang Yuantian if (rc == -1) 398547f45bSGary Bisson return CMD_RET_FAILURE; 40aa6ab905STang Yuantian sata_curr_device = rc; 41aa6ab905STang Yuantian } 422e192b24SSimon Glass 43*e29e71e9SSimon Glass return blk_common_cmd(argc, argv, IF_TYPE_SATA, &sata_curr_device); 442e192b24SSimon Glass } 452e192b24SSimon Glass 462e192b24SSimon Glass U_BOOT_CMD( 472e192b24SSimon Glass sata, 5, 1, do_sata, 482e192b24SSimon Glass "SATA sub system", 492e192b24SSimon Glass "init - init SATA sub system\n" 502e192b24SSimon Glass "sata stop - disable SATA sub system\n" 512e192b24SSimon Glass "sata info - show available SATA devices\n" 522e192b24SSimon Glass "sata device [dev] - show or set current device\n" 532e192b24SSimon Glass "sata part [dev] - print partition table\n" 542e192b24SSimon Glass "sata read addr blk# cnt\n" 552e192b24SSimon Glass "sata write addr blk# cnt" 562e192b24SSimon Glass ); 57