1/***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
--- 28 unchanged lines hidden (view full) ---
37 ***********************license end**************************************/
38
39/*
40 * octeon_ebt3000_cf.c
41 *
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/sys/mips/cavium/octeon_ebt3000_cf.c 242273 2012-10-29 00:51:53Z jmallett $");
46
47#include <sys/param.h>
48#include <sys/bio.h>
49#include <sys/systm.h>
50#include <sys/sysctl.h>
51#include <sys/ata.h>
52#include <sys/bus.h>
53#include <sys/kernel.h>
--- 267 unchanged lines hidden (view full) ---
321static int cf_cmd_read (uint32_t nr_sectors, uint32_t start_sector, void *buf)
322{
323 unsigned long lba;
324 uint32_t count;
325 uint16_t *ptr_16;
326 uint8_t *ptr_8;
327 int error;
328
329 ptr_8 = (uint8_t*)buf;
330 ptr_16 = (uint16_t*)buf;
331 lba = start_sector;
332
333 while (nr_sectors--) {
334 error = cf_send_cmd(lba, CMD_READ_SECTOR);
335 if (error != 0) {
336 printf("%s: cf_send_cmd(CMD_READ_SECTOR) failed: %d\n", __func__, error);
337 return (error);
338 }
339
340 switch (bus_type)
--- 15 unchanged lines hidden (view full) ---
356 if ((count & 0xf) == 0)
357 (void)cf_inb_16(TF_STATUS);
358 }
359 break;
360 }
361
362 lba++;
363 }
364 return (0);
365}
366
367
368/* ------------------------------------------------------------------- *
369 * cf_cmd_write() *
370 * ------------------------------------------------------------------- *
371 *
372 * Write nr_sectors to the device starting from start_sector.
373 */
374static int cf_cmd_write (uint32_t nr_sectors, uint32_t start_sector, void *buf)
375{
376 uint32_t lba;
377 uint32_t count;
378 uint16_t *ptr_16;
379 uint8_t *ptr_8;
380 int error;
381
382 lba = start_sector;
383 ptr_8 = (uint8_t*)buf;
384 ptr_16 = (uint16_t*)buf;
385
386 while (nr_sectors--) {
387 error = cf_send_cmd(lba, CMD_WRITE_SECTOR);
388 if (error != 0) {
389 printf("%s: cf_send_cmd(CMD_WRITE_SECTOR) failed: %d\n", __func__, error);
--- 18 unchanged lines hidden (view full) ---
408 if ((count & 0xf) == 0)
409 (void)cf_inb_16(TF_STATUS);
410 }
411 break;
412 }
413
414 lba++;
415 }
416 return (0);
417}
418
419
420/* ------------------------------------------------------------------- *
421 * cf_cmd_identify() *
422 * ------------------------------------------------------------------- *
423 *
--- 99 unchanged lines hidden (view full) ---
523 * This code originally spun on DRQ. If that behavior turns out to be
524 * necessary, a flag can be added or this function can be called
525 * repeatedly as long as it is returning ENXIO.
526 */
527static int cf_wait_busy (void)
528{
529 uint8_t status;
530
531 switch (bus_type)
532 {
533 case CF_8:
534 case CF_TRUE_IDE_8:
535 status = cf_inb_8(TF_STATUS);
536 while ((status & STATUS_BSY) == STATUS_BSY) {
537 if ((status & STATUS_DF) != 0) {
538 printf("%s: device fault (status=%x)\n", __func__, status);
--- 19 unchanged lines hidden (view full) ---
558
559 /* DRQ is only for when read data is actually available; check BSY */
560 /* Some vendors do assert DRQ, but not all. Check BSY instead. */
561 if (status & STATUS_BSY) {
562 printf("%s: device not ready (status=%x)\n", __func__, status);
563 return (ENXIO);
564 }
565
566 return (0);
567}
568
569/* ------------------------------------------------------------------- *
570 * cf_swap_ascii() *
571 * ------------------------------------------------------------------- *
572 *
573 * The ascii string returned by the controller specifying
--- 162 unchanged lines hidden ---
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
--- 28 unchanged lines hidden (view full) ---
37 ***********************license end**************************************/
38
39/*
40 * octeon_ebt3000_cf.c
41 *
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/sys/mips/cavium/octeon_ebt3000_cf.c 242273 2012-10-29 00:51:53Z jmallett $");
46
47#include <sys/param.h>
48#include <sys/bio.h>
49#include <sys/systm.h>
50#include <sys/sysctl.h>
51#include <sys/ata.h>
52#include <sys/bus.h>
53#include <sys/kernel.h>
--- 267 unchanged lines hidden (view full) ---
321static int cf_cmd_read (uint32_t nr_sectors, uint32_t start_sector, void *buf)
322{
323 unsigned long lba;
324 uint32_t count;
325 uint16_t *ptr_16;
326 uint8_t *ptr_8;
327 int error;
328
329 ptr_8 = (uint8_t*)buf;
330 ptr_16 = (uint16_t*)buf;
331 lba = start_sector;
332
333 while (nr_sectors--) {
334 error = cf_send_cmd(lba, CMD_READ_SECTOR);
335 if (error != 0) {
336 printf("%s: cf_send_cmd(CMD_READ_SECTOR) failed: %d\n", __func__, error);
337 return (error);
338 }
339
340 switch (bus_type)
--- 15 unchanged lines hidden (view full) ---
356 if ((count & 0xf) == 0)
357 (void)cf_inb_16(TF_STATUS);
358 }
359 break;
360 }
361
362 lba++;
363 }
364 return (0);
365}
366
367
368/* ------------------------------------------------------------------- *
369 * cf_cmd_write() *
370 * ------------------------------------------------------------------- *
371 *
372 * Write nr_sectors to the device starting from start_sector.
373 */
374static int cf_cmd_write (uint32_t nr_sectors, uint32_t start_sector, void *buf)
375{
376 uint32_t lba;
377 uint32_t count;
378 uint16_t *ptr_16;
379 uint8_t *ptr_8;
380 int error;
381
382 lba = start_sector;
383 ptr_8 = (uint8_t*)buf;
384 ptr_16 = (uint16_t*)buf;
385
386 while (nr_sectors--) {
387 error = cf_send_cmd(lba, CMD_WRITE_SECTOR);
388 if (error != 0) {
389 printf("%s: cf_send_cmd(CMD_WRITE_SECTOR) failed: %d\n", __func__, error);
--- 18 unchanged lines hidden (view full) ---
408 if ((count & 0xf) == 0)
409 (void)cf_inb_16(TF_STATUS);
410 }
411 break;
412 }
413
414 lba++;
415 }
416 return (0);
417}
418
419
420/* ------------------------------------------------------------------- *
421 * cf_cmd_identify() *
422 * ------------------------------------------------------------------- *
423 *
--- 99 unchanged lines hidden (view full) ---
523 * This code originally spun on DRQ. If that behavior turns out to be
524 * necessary, a flag can be added or this function can be called
525 * repeatedly as long as it is returning ENXIO.
526 */
527static int cf_wait_busy (void)
528{
529 uint8_t status;
530
531 switch (bus_type)
532 {
533 case CF_8:
534 case CF_TRUE_IDE_8:
535 status = cf_inb_8(TF_STATUS);
536 while ((status & STATUS_BSY) == STATUS_BSY) {
537 if ((status & STATUS_DF) != 0) {
538 printf("%s: device fault (status=%x)\n", __func__, status);
--- 19 unchanged lines hidden (view full) ---
558
559 /* DRQ is only for when read data is actually available; check BSY */
560 /* Some vendors do assert DRQ, but not all. Check BSY instead. */
561 if (status & STATUS_BSY) {
562 printf("%s: device not ready (status=%x)\n", __func__, status);
563 return (ENXIO);
564 }
565
566 return (0);
567}
568
569/* ------------------------------------------------------------------- *
570 * cf_swap_ascii() *
571 * ------------------------------------------------------------------- *
572 *
573 * The ascii string returned by the controller specifying
--- 162 unchanged lines hidden ---