<commit_before>/*
 * PATA driver for AT91SAM9260 Static Memory Controller
 * with CompactFlash interface in True IDE mode
 *
 * Copyright (C) 2009 <NAME>
 *
 * Based on:
 *      * generic platform driver by <NAME>: drivers/ata/pata_platform.c
 *      * pata_at32 driver by <NAME>
 *      * at91_ide driver by <NAME>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/gfp.h>
#include <scsi/scsi_host.h>
#include <linux/ata.h>
#include <linux/clk.h>
#include <linux/libata.h>
#include <linux/platform_device.h>
#include <linux/ata_platform.h>

#include <mach/at91sam9_smc.h>
#include <mach/board.h>
#include <mach/gpio.h>


#define DRV_NAME "pata_at91"
#define DRV_VERSION "0.2"

#define CF_IDE_OFFSET	    0x00c00000
#define CF_ALT_IDE_OFFSET   0x00e00000
#define CF_IDE_RES_SIZE     0x08
#define NCS_RD_PULSE_LIMIT  0x3f /* maximal value for pulse bitfields */

struct at91_ide_info {
	unsigned long mode;
	unsigned int cs;

	struct clk *mck;

	void __iomem *ide_addr;
	void __iomem *alt_addr;
};

static const struct ata_timing initial_timing =
	{XFER_PIO_0, 70, 290, 240, 600, 165, 150, 600, 0};

static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz)
{
	unsigned long mul;

	/*
	* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] =
	*     x * (f / 1_000_000_000) =
	*     x * ((f * 65536) / 1_000_000_000) / 65536 =
	*     x * (((f / 10_000) * 65536) / 100_000) / 65536 =
	*/

	mul = (mck_hz / 10000) << 16;
	mul /= 100000;

	return (ns * mul + 65536) >> 16;    /* rounding */
}

static void set_smc_mode(struct at91_ide_info *info)
{
	at91_sys_write(AT91_SMC_MODE(info->cs), info->mode);
	return;
}<commit_msg>ata: pata_at91.c bugfix for initial_timing initialisation<commit_after>/*
 * PATA driver for AT91SAM9260 Static Memory Controller
 * with CompactFlash interface in True IDE mode
 *
 * Copyright (C) 2009 <NAME>
 *
 * Based on:
 *      * generic platform driver by <NAME>: drivers/ata/pata_platform.c
 *      * pata_at32 driver by <NAME>
 *      * at91_ide driver by <NAME>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/gfp.h>
#include <scsi/scsi_host.h>
#include <linux/ata.h>
#include <linux/clk.h>
#include <linux/libata.h>
#include <linux/platform_device.h>
#include <linux/ata_platform.h>

#include <mach/at91sam9_smc.h>
#include <mach/board.h>
#include <mach/gpio.h>


#define DRV_NAME "pata_at91"
#define DRV_VERSION "0.2"

#define CF_IDE_OFFSET	    0x00c00000
#define CF_ALT_IDE_OFFSET   0x00e00000
#define CF_IDE_RES_SIZE     0x08
#define NCS_RD_PULSE_LIMIT  0x3f /* maximal value for pulse bitfields */

struct at91_ide_info {
	unsigned long mode;
	unsigned int cs;

	struct clk *mck;

	void __iomem *ide_addr;
	void __iomem *alt_addr;
};

static const struct ata_timing initial_timing = {
	.mode		= XFER_PIO_0,
	.setup		= 70,
	.act8b		= 290,
	.rec8b		= 240,
	.cyc8b		= 600,
	.active		= 165,
	.recover	= 150,
	.dmack_hold	= 0,
	.cycle		= 600,
	.udma		= 0
};

static unsigned long calc_mck_cycles(unsigned long ns, unsigned long mck_hz)
{
	unsigned long mul;

	/*
	* cycles = x [nsec] * f [Hz] / 10^9 [ns in sec] =
	*     x * (f / 1_000_000_000) =
	*     x * ((f * 65536) / 1_000_000_000) / 65536 =
	*     x * (((f / 10_000) * 65536) / 100_000) / 65536 =
	*/

	mul = (mck_hz / 10000) << 16;
	mul /= 100000;

	return (ns * mul + 65536) >> 16;    /* rounding */
}

static void set_smc_mode(struct at91_ide_info *info)
{
	at91_sys_write(AT91_SMC_MODE(info->cs), info->mode);
	return;
}
{'fraction_non_alphanumeric': 0.1261375126390293, 'fraction_numerical': 0.07583417593528817, 'mean_word_length': 3.5958188153310107, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7022404', 'n_tokens_mistral': 1807, 'n_tokens_neox': 1565, 'n_words': 420}