static int __init samsung_init(void)
{
        struct device *parent=NULL;	

	if (use_sabi && !dmi_check_system(samsung_sabi_dmi_table) && !force){
	    printk(KERN_ERR "Samsung-backlight is intended to work only with Samsung laptops.\n");
	    return -ENODEV;
	}
        if (!use_sabi && !dmi_check_system(samsung_dmi_table) && !force){
	    printk(KERN_ERR "Sorry, your laptop is not supported. Try use_sabi=1\n");
	    return -ENODEV;
        }

        if(use_sabi){
	    const char *test_str = "SwSmi@";
	    int pos;
	    int index = 0;
	    void __iomem *base;
	    unsigned int ifaceP;
	
	    mutex_init(&sabi_mutex);
	
	    f0000_segment = ioremap(0xf0000, 0xffff);
	    if (!f0000_segment) {
	        printk(KERN_ERR "Samsung-backlight: Can't map the segment at 0xf0000\n");
	        return -EINVAL;
	    }
	
	    printk(KERN_INFO "Samsung-backlight: checking for SABI support.\n");
	
	    /* Try to find the signature "SwSmi@" in memory to find the header */
	    base = f0000_segment;
	    for (pos = 0; pos < 0xffff; ++pos) {
	        char temp = readb(base + pos);
	        if (temp == test_str[index]) {
	            if (5 == index++)
	                break;
	        }
	        else {
	            index = 0;
	        }
	    }
	    if (pos == 0xffff) {
	        printk(KERN_INFO "Samsung-backlight: SABI is not supported\n");
	        iounmap(f0000_segment);
	        return -EINVAL;
	    }
	
	    sabi = (struct sabi_header __iomem *)(base + pos + 1);
	
	    printk(KERN_INFO "Samsung-backlight: SABI is supported (%x)\n", pos + 0xf0000 - 6);
	    if (debug) {
	        printk(KERN_DEBUG "SABI header:\n");
	        printk(KERN_DEBUG " SMI Port Number = 0x%04x\n", readw(&sabi->port));
	        printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n", readb(&sabi->iface_func));
	        printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n", readb(&sabi->en_mem));
	        printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n", readb(&sabi->re_mem));
	        printk(KERN_DEBUG " SABI data offset = 0x%04x\n", readw(&sabi->data_offset));
	        printk(KERN_DEBUG " SABI data segment = 0x%04x\n", readw(&sabi->data_segment));
	        printk(KERN_DEBUG " BIOS interface version = 0x%02x\n", readb(&sabi->bios_ifver));
	        printk(KERN_DEBUG " KBD Launcher string = 0x%02x\n", readb(&sabi->launcher_string));
	    }
	
	    /* Get a pointer to the SABI Interface */
	    ifaceP = (readw(&sabi->data_segment) & 0x0ffff) << 4;
	    ifaceP += readw(&sabi->data_offset) & 0x0ffff;
	    sabi_iface = (struct sabi_interface __iomem *)ioremap(ifaceP, 16);
	    if (!sabi_iface) {
	        printk(KERN_ERR "Samsung-backlight: Can't remap %x\n", ifaceP);
	        iounmap(f0000_segment);
	        return -EINVAL;
	    }
	
	    if (debug) {
	        printk(KERN_DEBUG "Samsung-backlight: SABI Interface = %p\n", sabi_iface);
	    }
        }else{
          /*
	   * The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
	   * NP-Q45 uses 0x2a02.  Odds are we might need to add more to the
	   * list over time...
	   */
          int pcidevids[]={0x27ae,0x2a02,0x2a42,0xa011,0};
	  int i;
          for(i=0, pci_device=NULL;pcidevids[i]>0 && pci_device==NULL;++i)
	    pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, pcidevids[i], NULL);
          if (!pci_device)
            return -ENODEV;
          parent=&pci_device->dev;
        }
 
        /* create a backlight device to talk to this one */
#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34)
	backlight_device = backlight_device_register("samsung",
						     parent,
						     NULL, &backlight_ops,NULL);
#else
	backlight_device = backlight_device_register("samsung",
						     parent,
						     NULL, &backlight_ops);
#endif
	if (IS_ERR(backlight_device)) {
                if(pci_device)
		  pci_dev_put(pci_device);
		return PTR_ERR(backlight_device);
	}

	backlight_device->props.max_brightness = use_sabi ? SABI_MAX_BRIGHT : MAX_BRIGHT;
	backlight_device->props.brightness = read_brightness();
	backlight_device->props.power = FB_BLANK_UNBLANK;
	backlight_update_status(backlight_device);

	return 0;
}
Exemple #2
0
static int snd_cht_mc_probe(struct platform_device *pdev)
{
	struct snd_soc_card *card = snd_soc_cards[0].soc_card;
	struct snd_soc_acpi_mach *mach;
	struct cht_mc_private *drv;
	const char *i2c_name = NULL;
	bool found = false;
	bool is_bytcr = false;
	int dai_index = 0;
	int ret_val = 0;
	int i;

	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
	if (!drv)
		return -ENOMEM;

	mach = (&pdev->dev)->platform_data;

	for (i = 0; i < ARRAY_SIZE(snd_soc_cards); i++) {
		if (acpi_dev_found(snd_soc_cards[i].codec_id) &&
			(!strncmp(snd_soc_cards[i].codec_id, mach->id, 8))) {
			dev_dbg(&pdev->dev,
				"found codec %s\n", snd_soc_cards[i].codec_id);
			card = snd_soc_cards[i].soc_card;
			drv->acpi_card = &snd_soc_cards[i];
			found = true;
			break;
		}
	}

	if (!found) {
		dev_err(&pdev->dev, "No matching HID found in supported list\n");
		return -ENODEV;
	}

	card->dev = &pdev->dev;
	sprintf(drv->codec_name, "i2c-%s:00", drv->acpi_card->codec_id);

	/* set correct codec name */
	for (i = 0; i < ARRAY_SIZE(cht_dailink); i++)
		if (!strcmp(card->dai_link[i].codec_name, "i2c-10EC5645:00")) {
			card->dai_link[i].codec_name = drv->codec_name;
			dai_index = i;
		}

	/* fixup codec name based on HID */
	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
	if (i2c_name) {
		snprintf(cht_rt5645_codec_name, sizeof(cht_rt5645_codec_name),
			"%s%s", "i2c-", i2c_name);
		cht_dailink[dai_index].codec_name = cht_rt5645_codec_name;
	}

	/*
	 * swap SSP0 if bytcr is detected
	 * (will be overridden if DMI quirk is detected)
	 */
	if (is_valleyview()) {
		if (mach->mach_params.acpi_ipc_irq_index == 0)
			is_bytcr = true;
	}

	if (is_bytcr) {
		/*
		 * Baytrail CR platforms may have CHAN package in BIOS, try
		 * to find relevant routing quirk based as done on Windows
		 * platforms. We have to read the information directly from the
		 * BIOS, at this stage the card is not created and the links
		 * with the codec driver/pdata are non-existent
		 */

		struct acpi_chan_package chan_package;

		/* format specified: 2 64-bit integers */
		struct acpi_buffer format = {sizeof("NN"), "NN"};
		struct acpi_buffer state = {0, NULL};
		struct snd_soc_acpi_package_context pkg_ctx;
		bool pkg_found = false;

		state.length = sizeof(chan_package);
		state.pointer = &chan_package;

		pkg_ctx.name = "CHAN";
		pkg_ctx.length = 2;
		pkg_ctx.format = &format;
		pkg_ctx.state = &state;
		pkg_ctx.data_valid = false;

		pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
							       &pkg_ctx);
		if (pkg_found) {
			if (chan_package.aif_value == 1) {
				dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
				cht_rt5645_quirk |= CHT_RT5645_SSP0_AIF1;
			} else  if (chan_package.aif_value == 2) {
				dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n");
				cht_rt5645_quirk |= CHT_RT5645_SSP0_AIF2;
			} else {
				dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n");
				pkg_found = false;
			}
		}

		if (!pkg_found) {
			/* no BIOS indications, assume SSP0-AIF2 connection */
			cht_rt5645_quirk |= CHT_RT5645_SSP0_AIF2;
		}
	}

	/* check quirks before creating card */
	dmi_check_system(cht_rt5645_quirk_table);
	log_quirks(&pdev->dev);

	if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) ||
		(cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) {

		/* fixup codec aif name */
		snprintf(cht_rt5645_codec_aif_name,
			sizeof(cht_rt5645_codec_aif_name),
			"%s", "rt5645-aif2");

		cht_dailink[dai_index].codec_dai_name =
			cht_rt5645_codec_aif_name;
	}

	if ((cht_rt5645_quirk & CHT_RT5645_SSP0_AIF1) ||
		(cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) {

		/* fixup cpu dai name name */
		snprintf(cht_rt5645_cpu_dai_name,
			sizeof(cht_rt5645_cpu_dai_name),
			"%s", "ssp0-port");

		cht_dailink[dai_index].cpu_dai_name =
			cht_rt5645_cpu_dai_name;
	}

	drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
	if (IS_ERR(drv->mclk)) {
		dev_err(&pdev->dev,
			"Failed to get MCLK from pmc_plt_clk_3: %ld\n",
			PTR_ERR(drv->mclk));
		return PTR_ERR(drv->mclk);
	}

	snd_soc_card_set_drvdata(card, drv);
	ret_val = devm_snd_soc_register_card(&pdev->dev, card);
	if (ret_val) {
		dev_err(&pdev->dev,
			"snd_soc_register_card failed %d\n", ret_val);
		return ret_val;
	}
	platform_set_drvdata(pdev, card);
	return ret_val;
}
Exemple #3
0
void __init dmi_check_pciprobe(void)
{
	dmi_check_system(pciprobe_dmi_table);
}
Exemple #4
0
static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
{
	unsigned int i;
	unsigned int valid_states = 0;
	unsigned int cpu = policy->cpu;
	struct acpi_cpufreq_data *data;
	unsigned int result = 0;
	struct cpuinfo_x86 *c = &cpu_data(policy->cpu);
	struct acpi_processor_performance *perf;
#ifdef CONFIG_SMP
	static int blacklisted;
#endif

	pr_debug("acpi_cpufreq_cpu_init\n");

#ifdef CONFIG_SMP
	if (blacklisted)
		return blacklisted;
	blacklisted = acpi_cpufreq_blacklist(c);
	if (blacklisted)
		return blacklisted;
#endif

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	if (!zalloc_cpumask_var(&data->freqdomain_cpus, GFP_KERNEL)) {
		result = -ENOMEM;
		goto err_free;
	}

	perf = per_cpu_ptr(acpi_perf_data, cpu);
	data->acpi_perf_cpu = cpu;
	policy->driver_data = data;

	if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
		acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;

	result = acpi_processor_register_performance(perf, cpu);
	if (result)
		goto err_free_mask;

	policy->shared_type = perf->shared_type;

	/*
	 * Will let policy->cpus know about dependency only when software
	 * coordination is required.
	 */
	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL ||
	    policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
		cpumask_copy(policy->cpus, perf->shared_cpu_map);
	}
	cpumask_copy(data->freqdomain_cpus, perf->shared_cpu_map);

#ifdef CONFIG_SMP
	dmi_check_system(sw_any_bug_dmi_table);
	if (bios_with_sw_any_bug && !policy_is_shared(policy)) {
		policy->shared_type = CPUFREQ_SHARED_TYPE_ALL;
		cpumask_copy(policy->cpus, topology_core_cpumask(cpu));
	}

	if (check_amd_hwpstate_cpu(cpu) && !acpi_pstate_strict) {
		cpumask_clear(policy->cpus);
		cpumask_set_cpu(cpu, policy->cpus);
		cpumask_copy(data->freqdomain_cpus,
			     topology_sibling_cpumask(cpu));
		policy->shared_type = CPUFREQ_SHARED_TYPE_HW;
		pr_info_once(PFX "overriding BIOS provided _PSD data\n");
	}
#endif

	/* capability check */
	if (perf->state_count <= 1) {
		pr_debug("No P-States\n");
		result = -ENODEV;
		goto err_unreg;
	}

	if (perf->control_register.space_id != perf->status_register.space_id) {
		result = -ENODEV;
		goto err_unreg;
	}

	switch (perf->control_register.space_id) {
	case ACPI_ADR_SPACE_SYSTEM_IO:
		if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
		    boot_cpu_data.x86 == 0xf) {
			pr_debug("AMD K8 systems must use native drivers.\n");
			result = -ENODEV;
			goto err_unreg;
		}
		pr_debug("SYSTEM IO addr space\n");
		data->cpu_feature = SYSTEM_IO_CAPABLE;
		break;
	case ACPI_ADR_SPACE_FIXED_HARDWARE:
		pr_debug("HARDWARE addr space\n");
		if (check_est_cpu(cpu)) {
			data->cpu_feature = SYSTEM_INTEL_MSR_CAPABLE;
			break;
		}
		if (check_amd_hwpstate_cpu(cpu)) {
			data->cpu_feature = SYSTEM_AMD_MSR_CAPABLE;
			break;
		}
		result = -ENODEV;
		goto err_unreg;
	default:
		pr_debug("Unknown addr space %d\n",
			(u32) (perf->control_register.space_id));
		result = -ENODEV;
		goto err_unreg;
	}

	data->freq_table = kzalloc(sizeof(*data->freq_table) *
		    (perf->state_count+1), GFP_KERNEL);
	if (!data->freq_table) {
		result = -ENOMEM;
		goto err_unreg;
	}

	/* detect transition latency */
	policy->cpuinfo.transition_latency = 0;
	for (i = 0; i < perf->state_count; i++) {
		if ((perf->states[i].transition_latency * 1000) >
		    policy->cpuinfo.transition_latency)
			policy->cpuinfo.transition_latency =
			    perf->states[i].transition_latency * 1000;
	}

	/* Check for high latency (>20uS) from buggy BIOSes, like on T42 */
	if (perf->control_register.space_id == ACPI_ADR_SPACE_FIXED_HARDWARE &&
	    policy->cpuinfo.transition_latency > 20 * 1000) {
		policy->cpuinfo.transition_latency = 20 * 1000;
		printk_once(KERN_INFO
			    "P-state transition latency capped at 20 uS\n");
	}

	/* table init */
	for (i = 0; i < perf->state_count; i++) {
		if (i > 0 && perf->states[i].core_frequency >=
		    data->freq_table[valid_states-1].frequency / 1000)
			continue;

		data->freq_table[valid_states].driver_data = i;
		data->freq_table[valid_states].frequency =
		    perf->states[i].core_frequency * 1000;
		valid_states++;
	}
	data->freq_table[valid_states].frequency = CPUFREQ_TABLE_END;
	perf->state = 0;

	result = cpufreq_table_validate_and_show(policy, data->freq_table);
	if (result)
		goto err_freqfree;

	if (perf->states[0].core_frequency * 1000 != policy->cpuinfo.max_freq)
		printk(KERN_WARNING FW_WARN "P-state 0 is not max freq\n");

	switch (perf->control_register.space_id) {
	case ACPI_ADR_SPACE_SYSTEM_IO:
		/*
		 * The core will not set policy->cur, because
		 * cpufreq_driver->get is NULL, so we need to set it here.
		 * However, we have to guess it, because the current speed is
		 * unknown and not detectable via IO ports.
		 */
		policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
		break;
	case ACPI_ADR_SPACE_FIXED_HARDWARE:
		acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
		break;
	default:
		break;
	}

	/* notify BIOS that we exist */
	acpi_processor_notify_smm(THIS_MODULE);

	pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
	for (i = 0; i < perf->state_count; i++)
		pr_debug("     %cP%d: %d MHz, %d mW, %d uS\n",
			(i == perf->state ? '*' : ' '), i,
			(u32) perf->states[i].core_frequency,
			(u32) perf->states[i].power,
			(u32) perf->states[i].transition_latency);

	/*
	 * the first call to ->target() should result in us actually
	 * writing something to the appropriate registers.
	 */
	data->resume = 1;

	return result;

err_freqfree:
	kfree(data->freq_table);
err_unreg:
	acpi_processor_unregister_performance(cpu);
err_free_mask:
	free_cpumask_var(data->freqdomain_cpus);
err_free:
	kfree(data);
	policy->driver_data = NULL;

	return result;
}
Exemple #5
0
int __cpuinit acpi_processor_power_init(struct acpi_processor *pr,
			      struct acpi_device *device)
{
	acpi_status status = 0;
	static int first_run;
#ifdef CONFIG_ACPI_PROCFS
	struct proc_dir_entry *entry = NULL;
#endif

	if (boot_option_idle_override)
		return 0;

	if (!first_run) {
		if (idle_halt) {
			/*
			 * When the boot option of "idle=halt" is added, halt
			 * is used for CPU IDLE.
			 * In such case C2/C3 is meaningless. So the max_cstate
			 * is set to one.
			 */
			max_cstate = 1;
		}
		dmi_check_system(processor_power_dmi_table);
		max_cstate = acpi_processor_cstate_check(max_cstate);
		if (max_cstate < ACPI_C_STATES_MAX)
			printk(KERN_NOTICE
			       "ACPI: processor limited to max C-state %d\n",
			       max_cstate);
		first_run++;
	}

	if (!pr)
		return -EINVAL;

	if (acpi_gbl_FADT.cst_control && !nocst) {
		status =
		    acpi_os_write_port(acpi_gbl_FADT.smi_command, acpi_gbl_FADT.cst_control, 8);
		if (ACPI_FAILURE(status)) {
			ACPI_EXCEPTION((AE_INFO, status,
					"Notifying BIOS of _CST ability failed"));
		}
	}

	acpi_processor_get_power_info(pr);
	pr->flags.power_setup_done = 1;

	/*
	 * Install the idle handler if processor power management is supported.
	 * Note that we use previously set idle handler will be used on
	 * platforms that only support C1.
	 */
	if (pr->flags.power) {
		acpi_processor_setup_cpuidle(pr);
		if (cpuidle_register_device(&pr->power.dev))
			return -EIO;
	}
#ifdef CONFIG_ACPI_PROCFS
	/* 'power' [R] */
	entry = proc_create_data(ACPI_PROCESSOR_FILE_POWER,
				 S_IRUGO, acpi_device_dir(device),
				 &acpi_processor_power_fops,
				 acpi_driver_data(device));
	if (!entry)
		return -EIO;
#endif
	return 0;
}
Exemple #6
0
/**
 * intel_parse_bios - find VBT and initialize settings from the BIOS
 * @dev: DRM device
 *
 * Loads the Video BIOS and checks that the VBT exists.  Sets scratch registers
 * to appropriate values.
 *
 * Returns 0 on success, nonzero on failure.
 */
bool
intel_parse_bios(struct drm_device *dev)
{
	struct drm_i915_private *dev_priv = dev->dev_private;
	struct pci_dev *pdev = dev->pdev;
	struct bdb_header *bdb = NULL;
	u8 __iomem *bios = NULL;

	init_vbt_defaults(dev_priv);

	/* XXX Should this validation be moved to intel_opregion.c? */
	if (!dmi_check_system(intel_no_opregion_vbt) && dev_priv->opregion.vbt) {
		struct vbt_header *vbt = dev_priv->opregion.vbt;
		if (memcmp(vbt->signature, "$VBT", 4) == 0) {
			DRM_DEBUG_KMS("Using VBT from OpRegion: %20s\n",
					 vbt->signature);
			bdb = (struct bdb_header *)((char *)vbt + vbt->bdb_offset);
		} else
			dev_priv->opregion.vbt = NULL;
	}

	if (bdb == NULL) {
		struct vbt_header *vbt = NULL;
		size_t size;
		int i;

		bios = pci_map_rom(pdev, &size);
		if (!bios)
			return -1;

		/* Scour memory looking for the VBT signature */
		for (i = 0; i + 4 < size; i++) {
			if (!memcmp(bios + i, "$VBT", 4)) {
				vbt = (struct vbt_header *)(bios + i);
				break;
			}
		}

		if (!vbt) {
			DRM_ERROR("VBT signature missing\n");
			pci_unmap_rom(pdev, bios);
			return -1;
		}

		bdb = (struct bdb_header *)(bios + i + vbt->bdb_offset);
	}

	/* Grab useful general definitions */
	parse_general_features(dev_priv, bdb);
	parse_general_definitions(dev_priv, bdb);
	parse_lfp_panel_data(dev_priv, bdb);
	parse_sdvo_panel_data(dev_priv, bdb);
	parse_sdvo_device_mapping(dev_priv, bdb);
	parse_device_mapping(dev_priv, bdb);
	parse_driver_features(dev_priv, bdb);
	parse_edp(dev_priv, bdb);

	if (bios)
		pci_unmap_rom(pdev, bios);

	return 0;
}
static int __init msi_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	if (!force && !dmi_check_system(msi_dmi_table))
		return -ENODEV;

	if (auto_brightness < 0 || auto_brightness > 2)
		return -EINVAL;

	/* Register backlight stuff */

	msibl_device = backlight_device_register("msi-laptop-bl", NULL, NULL,
						&msibl_ops);
	if (IS_ERR(msibl_device))
		return PTR_ERR(msibl_device);

	msibl_device->props.max_brightness = MSI_LCD_LEVEL_MAX-1,

	ret = platform_driver_register(&msipf_driver);
	if (ret)
		goto fail_backlight;

	/* Register platform stuff */

	msipf_device = platform_device_alloc("msi-laptop-pf", -1);
	if (!msipf_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(msipf_device);
	if (ret)
		goto fail_platform_device1;

	ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group);
	if (ret)
		goto fail_platform_device2;

	/* Disable automatic brightness control by default because
	 * this module was probably loaded to do brightness control in
	 * software. */

	if (auto_brightness != 2)
		set_auto_brightness(auto_brightness);

	printk(KERN_INFO "msi-laptop: driver "MSI_DRIVER_VERSION" successfully loaded.\n");

	return 0;

fail_platform_device2:

	platform_device_del(msipf_device);

fail_platform_device1:

	platform_device_put(msipf_device);

fail_platform_driver:

	platform_driver_unregister(&msipf_driver);

fail_backlight:

	backlight_device_unregister(msibl_device);

	return ret;
}
Exemple #8
0
static int __init nvidiabl_init(void)
#endif
{
	int err; 
        unsigned back;
        s64 calc;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
        struct backlight_properties props;
#endif
        
	/* Bail-out if PCI subsystem is not initialized */
	if (no_pci_devices())
		return -ENODEV;

	printk(KERN_INFO "nvidiabl: loading driver version " NVIDIABL_VERSION_STR "\n");
	
	/* Check DMI whether we need to ignore some device */
	dmi_check_system(nvidiabl_ignore_table);
        
        /* Check DMI whether we have a known system */
        dmi_check_system(nvidiabl_dmi_table);

        err = nvidiabl_find_device(&driver_data, pci_id, nvidiabl_ignore_device);
        if (err)
                return err;
        
        nvidiabl_force_model(&driver_data);
        
        /* Map smartdimmer */
	err = nvidiabl_map_smartdimmer(driver_data);
	if (err)
		return err;
        
	/* Register at backlight framework */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)
        memset(&props, 0, sizeof(struct backlight_properties));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39)
	{
		char *p, *q;
		props.type = BACKLIGHT_TYPE_MAX-1;
		/* if the parameter string doesn't match type will = 1 a.k.a. BACKLIGHT_RAW */
		for (p = bl_type, q = (char *)bl_types[props.type]; props.type >= 1; props.type--)
			while (*p++ == *q++)
				if (*p == 0 && *q == 0)
					goto props;
	}
	props:
#endif
	nvidiabl_device = backlight_device_register("nvidia_backlight", NULL,
	                                             driver_data,
	                                             &driver_data->backlight_ops,
	                                             &props);
#else
        nvidiabl_device = backlight_device_register("nvidia_backlight", NULL,
                                                     driver_data,
                                                     &driver_data->backlight_ops);
#endif
                                                     
	if (IS_ERR(nvidiabl_device)) {
		nvidiabl_unmap_smartdimmer(driver_data);
		return PTR_ERR(nvidiabl_device);
	}


        back = driver_data->backup(driver_data);
        printk(KERN_INFO "nvidiabl: backup register value 0x%x\n", back);

        if (max == NVIDIABL_UNSET)
                driver_data->max = NVIDIABL_AUTO;
        else if (max != NVIDIABL_DEFAULT)
                driver_data->max = max;
          
        if (driver_data->max == NVIDIABL_AUTO) {
                printk(KERN_INFO "nvidiabl: autodetecting maximum\n");
                driver_data->max = driver_data->autodetect(driver_data, T_NVIDIABL_MAX);
        }
        printk(KERN_INFO "nvidiabl: using value 0x%x as maximum\n", driver_data->max);

        
        if (off == NVIDIABL_UNSET)
                driver_data->off = NVIDIABL_AUTO;
        else if (off != NVIDIABL_DEFAULT)
                driver_data->off = off;

        if (driver_data->off == NVIDIABL_AUTO) {
                printk(KERN_INFO "nvidiabl: autodetecting off\n");
                driver_data->off = driver_data->autodetect(driver_data, T_NVIDIABL_OFF);
        }
        
        if (driver_data->off < 0) {
                printk(KERN_INFO "nvidiabl: off is %d%% of maximum\n", -1 * driver_data->off);
                calc = driver_data->max * (-1 * driver_data->off);
                do_div(calc, 100);
                driver_data->off = calc;
        }
        printk(KERN_INFO "nvidiabl: using value 0x%x as off\n", driver_data->off);


        if (min == NVIDIABL_UNSET)
                driver_data->min = NVIDIABL_AUTO;
        else if (min != NVIDIABL_DEFAULT)
                driver_data->min = min;

        if (driver_data->min == NVIDIABL_AUTO) {
                printk(KERN_INFO "nvidiabl: autodetecting minimum\n");
                driver_data->min = driver_data->autodetect(driver_data, T_NVIDIABL_MIN);
        }
        
        if (driver_data->min < 0) {
                printk(KERN_INFO "nvidiabl: minimum is %d%% of maximum\n", -1 * driver_data->min);
                calc = driver_data->max * (-1 * driver_data->min);
                do_div(calc, 100);
                driver_data->min = calc;
        }
        printk(KERN_INFO "nvidiabl: using value 0x%x as minimum\n", driver_data->min);
        
        
        /* Set up backlight device */
        nvidiabl_device->props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
	nvidiabl_device->props.brightness =
		nvidiabl_device->ops->get_brightness(nvidiabl_device);
	backlight_update_status(nvidiabl_device);
	return 0;
}
Exemple #9
0
static int __init compal_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	if (!force && !dmi_check_system(compal_dmi_table))
		return -ENODEV;

	

	if (!acpi_video_backlight_support()) {
		compalbl_device = backlight_device_register("compal-laptop", NULL, NULL,
							    &compalbl_ops);
		if (IS_ERR(compalbl_device))
			return PTR_ERR(compalbl_device);

		compalbl_device->props.max_brightness = COMPAL_LCD_LEVEL_MAX-1;
	}

	ret = platform_driver_register(&compal_driver);
	if (ret)
		goto fail_backlight;

	

	compal_device = platform_device_alloc("compal-laptop", -1);
	if (!compal_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(compal_device);
	if (ret)
		goto fail_platform_device1;

	ret = sysfs_create_group(&compal_device->dev.kobj,
		&compal_attribute_group);
	if (ret)
		goto fail_platform_device2;

	printk(KERN_INFO "compal-laptop: driver "COMPAL_DRIVER_VERSION
		" successfully loaded.\n");

	return 0;

fail_platform_device2:

	platform_device_del(compal_device);

fail_platform_device1:

	platform_device_put(compal_device);

fail_platform_driver:

	platform_driver_unregister(&compal_driver);

fail_backlight:

	backlight_device_unregister(compalbl_device);

	return ret;
}
Exemple #10
0
static int __init hdaps_init(void)
{
	struct input_dev *idev;
	int ret;

	if (!dmi_check_system(hdaps_whitelist)) {
		printk(KERN_WARNING "hdaps: supported laptop not found!\n");
		ret = -ENODEV;
		goto out;
	}

	if (!request_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS, "hdaps")) {
		ret = -ENXIO;
		goto out;
	}

	ret = platform_driver_register(&hdaps_driver);
	if (ret)
		goto out_region;

	pdev = platform_device_register_simple("hdaps", -1, NULL, 0);
	if (IS_ERR(pdev)) {
		ret = PTR_ERR(pdev);
		goto out_driver;
	}

	ret = sysfs_create_group(&pdev->dev.kobj, &hdaps_attribute_group);
	if (ret)
		goto out_device;

	hdaps_idev = input_allocate_polled_device();
	if (!hdaps_idev) {
		ret = -ENOMEM;
		goto out_group;
	}

	hdaps_idev->poll = hdaps_mousedev_poll;
	hdaps_idev->poll_interval = HDAPS_POLL_INTERVAL;

	
	hdaps_calibrate();

	
	idev = hdaps_idev->input;
	idev->name = "hdaps";
	idev->phys = "isa1600/input0";
	idev->id.bustype = BUS_ISA;
	idev->dev.parent = &pdev->dev;
	idev->evbit[0] = BIT_MASK(EV_ABS);
	input_set_abs_params(idev, ABS_X,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
	input_set_abs_params(idev, ABS_Y,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);

	ret = input_register_polled_device(hdaps_idev);
	if (ret)
		goto out_idev;

	printk(KERN_INFO "hdaps: driver successfully loaded.\n");
	return 0;

out_idev:
	input_free_polled_device(hdaps_idev);
out_group:
	sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
out_device:
	platform_device_unregister(pdev);
out_driver:
	platform_driver_unregister(&hdaps_driver);
out_region:
	release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
out:
	printk(KERN_WARNING "hdaps: driver init failed (ret=%d)!\n", ret);
	return ret;
}
Exemple #11
0
static void ide_gd_shutdown(ide_drive_t *drive)
{
#ifdef	CONFIG_ALPHA
    /* On Alpha, halt(8) doesn't actually turn the machine off,
       it puts you into the sort of firmware monitor. Typically,
       it's used to boot another kernel image, so it's not much
       different from reboot(8). Therefore, we don't need to
       spin down the disk in this case, especially since Alpha
       firmware doesn't handle disks in standby mode properly.
       On the other hand, it's reasonably safe to turn the power
       off when the shutdown process reaches the firmware prompt,
       as the firmware initialization takes rather long time -
       at least 10 seconds, which should be sufficient for
       the disk to expire its write cache. */
    if (system_state != SYSTEM_POWER_OFF) {
#else
    if (system_state == SYSTEM_RESTART &&
            !dmi_check_system(ide_coldreboot_table)) {
#endif
        drive->disk_ops->flush(drive);
        return;
    }

    ;

    drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
}

#ifdef CONFIG_IDE_PROC_FS
static ide_proc_entry_t *ide_disk_proc_entries(ide_drive_t *drive)
{
    return (drive->media == ide_disk) ? ide_disk_proc : ide_floppy_proc;
}

static const struct ide_proc_devset *ide_disk_proc_devsets(ide_drive_t *drive)
{
    return (drive->media == ide_disk) ? ide_disk_settings
           : ide_floppy_settings;
}
#endif

static ide_startstop_t ide_gd_do_request(ide_drive_t *drive,
        struct request *rq, sector_t sector)
{
    return drive->disk_ops->do_request(drive, rq, sector);
}

static struct ide_driver ide_gd_driver = {
    .gen_driver = {
        .owner		= THIS_MODULE,
        .name		= "ide-gd",
        .bus		= &ide_bus_type,
    },
    .probe			= ide_gd_probe,
    .remove			= ide_gd_remove,
    .resume			= ide_gd_resume,
    .shutdown		= ide_gd_shutdown,
    .version		= IDE_GD_VERSION,
    .do_request		= ide_gd_do_request,
#ifdef CONFIG_IDE_PROC_FS
    .proc_entries		= ide_disk_proc_entries,
    .proc_devsets		= ide_disk_proc_devsets,
#endif
};
Exemple #12
0
static int __init acpisleep_dmi_init(void)
{
	dmi_check_system(acpisleep_dmi_table);
	return 0;
}
Exemple #13
0
static int __init msi_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	dmi_check_system(msi_dmi_table);
	if (!quirks)
		/* quirks may be NULL if no match in DMI table */
		quirks = &quirk_load_scm_model;
	if (force)
		quirks = &quirk_old_ec_model;

	if (!quirks->old_ec_model)
		get_threeg_exists();

	if (auto_brightness < 0 || auto_brightness > 2)
		return -EINVAL;

	/* Register backlight stuff */

	if (!quirks->old_ec_model || acpi_video_backlight_support()) {
		pr_info("Brightness ignored, must be controlled by ACPI video driver\n");
	} else {
		struct backlight_properties props;
		memset(&props, 0, sizeof(struct backlight_properties));
		props.type = BACKLIGHT_PLATFORM;
		props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
		msibl_device = backlight_device_register("msi-laptop-bl", NULL,
							 NULL, &msibl_ops,
							 &props);
		if (IS_ERR(msibl_device))
			return PTR_ERR(msibl_device);
	}

	ret = platform_driver_register(&msipf_driver);
	if (ret)
		goto fail_backlight;

	/* Register platform stuff */

	msipf_device = platform_device_alloc("msi-laptop-pf", -1);
	if (!msipf_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(msipf_device);
	if (ret)
		goto fail_platform_device1;

	if (quirks->load_scm_model && (load_scm_model_init(msipf_device) < 0)) {
		ret = -EINVAL;
		goto fail_platform_device1;
	}

	ret = sysfs_create_group(&msipf_device->dev.kobj,
				 &msipf_attribute_group);
	if (ret)
		goto fail_platform_device2;

	if (!quirks->old_ec_model) {
		if (threeg_exists)
			ret = device_create_file(&msipf_device->dev,
						&dev_attr_threeg);
		if (ret)
			goto fail_platform_device2;
	} else {
		ret = sysfs_create_group(&msipf_device->dev.kobj,
					 &msipf_old_attribute_group);
		if (ret)
			goto fail_platform_device2;

		/* Disable automatic brightness control by default because
		 * this module was probably loaded to do brightness control in
		 * software. */

		if (auto_brightness != 2)
			set_auto_brightness(auto_brightness);
	}

	pr_info("driver " MSI_DRIVER_VERSION " successfully loaded\n");

	return 0;

fail_platform_device2:

	if (quirks->load_scm_model) {
		i8042_remove_filter(msi_laptop_i8042_filter);
		cancel_delayed_work_sync(&msi_rfkill_dwork);
		cancel_work_sync(&msi_rfkill_work);
		rfkill_cleanup();
	}
	platform_device_del(msipf_device);

fail_platform_device1:

	platform_device_put(msipf_device);

fail_platform_driver:

	platform_driver_unregister(&msipf_driver);

fail_backlight:

	backlight_device_unregister(msibl_device);

	return ret;
}
Exemple #14
0
static int __init ibm_rtl_init(void) {
	unsigned long ebda_addr, ebda_size;
	unsigned int ebda_kb;
	int ret = -ENODEV, i;

	if (force)
		pr_warn("module loaded by force\n");
	/* first ensure that we are running on IBM HW */
	else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table))
		return -ENODEV;

	/* Get the address for the Extended BIOS Data Area */
	ebda_addr = get_bios_ebda();
	if (!ebda_addr) {
		RTL_DEBUG("no BIOS EBDA found\n");
		return -ENODEV;
	}

	ebda_map = ioremap(ebda_addr, 4);
	if (!ebda_map)
		return -ENOMEM;

	/* First word in the EDBA is the Size in KB */
	ebda_kb = ioread16(ebda_map);
	RTL_DEBUG("EBDA is %d kB\n", ebda_kb);

	if (ebda_kb == 0)
		goto out;

	iounmap(ebda_map);
	ebda_size = ebda_kb*1024;

	/* Remap the whole table */
	ebda_map = ioremap(ebda_addr, ebda_size);
	if (!ebda_map)
		return -ENOMEM;

	/* search for the _RTL_ signature at the start of the table */
	for (i = 0 ; i < ebda_size/sizeof(unsigned int); i++) {
		struct ibm_rtl_table __iomem * tmp;
		tmp = (struct ibm_rtl_table __iomem *) (ebda_map+i);
		if ((readq(&tmp->signature) & RTL_MASK) == RTL_SIGNATURE) {
			phys_addr_t addr;
			unsigned int plen;
			RTL_DEBUG("found RTL_SIGNATURE at %p\n", tmp);
			rtl_table = tmp;
			/* The address, value, width and offset are platform
			 * dependent and found in the ibm_rtl_table */
			rtl_cmd_width = ioread8(&rtl_table->cmd_granularity);
			rtl_cmd_type = ioread8(&rtl_table->cmd_address_type);
			RTL_DEBUG("rtl_cmd_width = %u, rtl_cmd_type = %u\n",
				  rtl_cmd_width, rtl_cmd_type);
			addr = ioread32(&rtl_table->cmd_port_address);
			RTL_DEBUG("addr = %#llx\n", (unsigned long long)addr);
			plen = rtl_cmd_width/sizeof(char);
			rtl_cmd_addr = rtl_port_map(addr, plen);
			RTL_DEBUG("rtl_cmd_addr = %p\n", rtl_cmd_addr);
			if (!rtl_cmd_addr) {
				ret = -ENOMEM;
				break;
			}
			ret = rtl_setup_sysfs();
			break;
		}
	}

out:
	if (ret) {
		iounmap(ebda_map);
		rtl_port_unmap(rtl_cmd_addr);
	}

	return ret;
}
Exemple #15
0
static int __init hdaps_init(void)
{
	int ret;

	/* Determine axis orientation orientation */
	if (hdaps_invert == HDAPS_ORIENT_UNDEFINED) /* set by module param? */
		if (dmi_check_system(hdaps_whitelist) < 1) /* in whitelist? */
			hdaps_invert = 0; /* default */

	/* Init timer before platform_driver_register, in case of suspend */
	init_timer(&hdaps_timer);
	hdaps_timer.function = hdaps_mousedev_poll;
	ret = platform_driver_register(&hdaps_driver);
	if (ret)
		goto out;

	pdev = platform_device_register_simple("hdaps", -1, NULL, 0);
	if (IS_ERR(pdev)) {
		ret = PTR_ERR(pdev);
		goto out_driver;
	}

	ret = sysfs_create_group(&pdev->dev.kobj, &hdaps_attribute_group);
	if (ret)
		goto out_device;

	hdaps_idev = input_allocate_device();
	if (!hdaps_idev) {
		ret = -ENOMEM;
		goto out_group;
	}

	hdaps_idev_raw = input_allocate_device();
	if (!hdaps_idev_raw) {
		ret = -ENOMEM;
		goto out_idev_first;
	}

	/* calibration for the input device (deferred to avoid delay) */
	needs_calibration = 1;

	/* initialize the joystick-like fuzzed input device */
	hdaps_idev->name = "ThinkPad HDAPS joystick emulation";
	hdaps_idev->phys = "hdaps/input0";
	hdaps_idev->id.bustype = BUS_HOST;
	hdaps_idev->id.vendor  = HDAPS_INPUT_VENDOR;
	hdaps_idev->id.product = HDAPS_INPUT_PRODUCT;
	hdaps_idev->id.version = HDAPS_INPUT_JS_VERSION;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
	hdaps_idev->cdev.dev = &pdev->dev;
#endif
	hdaps_idev->evbit[0] = BIT(EV_ABS);
	hdaps_idev->open = hdaps_mousedev_open;
	hdaps_idev->close = hdaps_mousedev_close;
	input_set_abs_params(hdaps_idev, ABS_X,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
	input_set_abs_params(hdaps_idev, ABS_Y,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);

	ret = input_register_device(hdaps_idev);
	if (ret)
		goto out_idev;

	/* initialize the raw data input device */
	hdaps_idev_raw->name = "ThinkPad HDAPS accelerometer data";
	hdaps_idev_raw->phys = "hdaps/input1";
	hdaps_idev_raw->id.bustype = BUS_HOST;
	hdaps_idev_raw->id.vendor  = HDAPS_INPUT_VENDOR;
	hdaps_idev_raw->id.product = HDAPS_INPUT_PRODUCT;
	hdaps_idev_raw->id.version = HDAPS_INPUT_RAW_VERSION;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)
	hdaps_idev_raw->cdev.dev = &pdev->dev;
#endif
	hdaps_idev_raw->evbit[0] = BIT(EV_ABS);
	hdaps_idev_raw->open = hdaps_mousedev_open;
	hdaps_idev_raw->close = hdaps_mousedev_close;
	input_set_abs_params(hdaps_idev_raw, ABS_X, -32768, 32767, 0, 0);
	input_set_abs_params(hdaps_idev_raw, ABS_Y, -32768, 32767, 0, 0);

	ret = input_register_device(hdaps_idev_raw);
	if (ret)
		goto out_idev_reg_first;

	pr_info("driver successfully loaded.\n");
	return 0;

out_idev_reg_first:
	input_unregister_device(hdaps_idev);
out_idev:
	input_free_device(hdaps_idev_raw);
out_idev_first:
	input_free_device(hdaps_idev);
out_group:
	sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
out_device:
	platform_device_unregister(pdev);
out_driver:
	platform_driver_unregister(&hdaps_driver);
	hdaps_device_shutdown();
out:
	pr_warn("driver init failed (ret=%d)!\n", ret);
	return ret;
}
static int __init msi_init(void)
{
	int ret;

	if (acpi_disabled)
		return -ENODEV;

	if (force || dmi_check_system(msi_dmi_table))
		old_ec_model = 1;

	if (!old_ec_model)
		get_threeg_exists();

	if (!old_ec_model && dmi_check_system(msi_load_scm_models_dmi_table))
		load_scm_model = 1;

	if (auto_brightness < 0 || auto_brightness > 2)
		return -EINVAL;

	/* Register backlight stuff */

	if (acpi_video_backlight_support()) {
		printk(KERN_INFO "MSI: Brightness ignored, must be controlled "
		       "by ACPI video driver\n");
	} else {
		struct backlight_properties props;
		memset(&props, 0, sizeof(struct backlight_properties));
		props.max_brightness = MSI_LCD_LEVEL_MAX - 1;
		msibl_device = backlight_device_register("msi-laptop-bl", NULL,
							 NULL, &msibl_ops,
							 &props);
		if (IS_ERR(msibl_device))
			return PTR_ERR(msibl_device);
	}

	ret = platform_driver_register(&msipf_driver);
	if (ret)
		goto fail_backlight;

	/* Register platform stuff */

	msipf_device = platform_device_alloc("msi-laptop-pf", -1);
	if (!msipf_device) {
		ret = -ENOMEM;
		goto fail_platform_driver;
	}

	ret = platform_device_add(msipf_device);
	if (ret)
		goto fail_platform_device1;

	if (load_scm_model && (load_scm_model_init(msipf_device) < 0)) {
		ret = -EINVAL;
		goto fail_platform_device1;
	}

	ret = sysfs_create_group(&msipf_device->dev.kobj, &msipf_attribute_group);
	if (ret)
		goto fail_platform_device2;

	if (!old_ec_model) {
		if (threeg_exists)
			ret = device_create_file(&msipf_device->dev,
						&dev_attr_threeg);
		if (ret)
			goto fail_platform_device2;
	}

	/* Disable automatic brightness control by default because
	 * this module was probably loaded to do brightness control in
	 * software. */

	if (auto_brightness != 2)
		set_auto_brightness(auto_brightness);

	printk(KERN_INFO "msi-laptop: driver "MSI_DRIVER_VERSION" successfully loaded.\n");

	return 0;

fail_platform_device2:

	platform_device_del(msipf_device);

fail_platform_device1:

	platform_device_put(msipf_device);

fail_platform_driver:

	platform_driver_unregister(&msipf_driver);

fail_backlight:

	backlight_device_unregister(msibl_device);

	return ret;
}
Exemple #17
0
static int __init ioport_quirks_init(void)
{
    dmi_check_system(ioport_quirks_tbl);
    return 0;
}
void __init io_delay_init(void)
{
	if (!io_delay_override)
		dmi_check_system(io_delay_0xed_port_dmi_table);
}
Exemple #19
0
static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
{
	const char * const mic_name[] = { "dmic", "in1", "in2", "in12" };
	struct byt_rt5651_private *priv;
	struct snd_soc_acpi_mach *mach;
	struct device *codec_dev;
	const char *i2c_name = NULL;
	const char *hp_swapped;
	bool is_bytcr = false;
	int ret_val = 0;
	int dai_index = 0;
	int i;

	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
	if (!priv)
		return -ENOMEM;

	/* register the soc card */
	byt_rt5651_card.dev = &pdev->dev;

	mach = byt_rt5651_card.dev->platform_data;
	snd_soc_card_set_drvdata(&byt_rt5651_card, priv);

	/* fix index of codec dai */
	for (i = 0; i < ARRAY_SIZE(byt_rt5651_dais); i++) {
		if (!strcmp(byt_rt5651_dais[i].codec_name, "i2c-10EC5651:00")) {
			dai_index = i;
			break;
		}
	}

	/* fixup codec name based on HID */
	i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1);
	if (!i2c_name) {
		dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id);
		return -ENODEV;
	}
	snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name),
		"%s%s", "i2c-", i2c_name);
	byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name;

	codec_dev = bus_find_device_by_name(&i2c_bus_type, NULL,
					    byt_rt5651_codec_name);
	if (!codec_dev)
		return -EPROBE_DEFER;

	/*
	 * swap SSP0 if bytcr is detected
	 * (will be overridden if DMI quirk is detected)
	 */
	if (x86_match_cpu(baytrail_cpu_ids)) {
		struct sst_platform_info *p_info = mach->pdata;
		const struct sst_res_info *res_info = p_info->res_info;

		if (res_info->acpi_ipc_irq_index == 0)
			is_bytcr = true;
	}

	if (is_bytcr) {
		/*
		 * Baytrail CR platforms may have CHAN package in BIOS, try
		 * to find relevant routing quirk based as done on Windows
		 * platforms. We have to read the information directly from the
		 * BIOS, at this stage the card is not created and the links
		 * with the codec driver/pdata are non-existent
		 */

		struct acpi_chan_package chan_package;

		/* format specified: 2 64-bit integers */
		struct acpi_buffer format = {sizeof("NN"), "NN"};
		struct acpi_buffer state = {0, NULL};
		struct snd_soc_acpi_package_context pkg_ctx;
		bool pkg_found = false;

		state.length = sizeof(chan_package);
		state.pointer = &chan_package;

		pkg_ctx.name = "CHAN";
		pkg_ctx.length = 2;
		pkg_ctx.format = &format;
		pkg_ctx.state = &state;
		pkg_ctx.data_valid = false;

		pkg_found = snd_soc_acpi_find_package_from_hid(mach->id,
							       &pkg_ctx);
		if (pkg_found) {
			if (chan_package.aif_value == 1) {
				dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n");
				byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF1;
			} else  if (chan_package.aif_value == 2) {
				dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n");
				byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2;
			} else {
				dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n");
				pkg_found = false;
			}
		}

		if (!pkg_found) {
			/* no BIOS indications, assume SSP0-AIF2 connection */
			byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2;
		}
	}

	/* check quirks before creating card */
	dmi_check_system(byt_rt5651_quirk_table);

	/* Must be called before register_card, also see declaration comment. */
	ret_val = byt_rt5651_add_codec_device_props(codec_dev);
	if (ret_val) {
		put_device(codec_dev);
		return ret_val;
	}

	/* Cherry Trail devices use an external amplifier enable gpio */
	if (x86_match_cpu(cherrytrail_cpu_ids)) {
		snd_byt_rt5651_mc_add_amp_en_gpio_mapping(codec_dev);
		priv->ext_amp_gpio = devm_fwnode_get_index_gpiod_from_child(
						&pdev->dev, "ext-amp-enable", 0,
						codec_dev->fwnode,
						GPIOD_OUT_LOW, "speaker-amp");
		if (IS_ERR(priv->ext_amp_gpio)) {
			ret_val = PTR_ERR(priv->ext_amp_gpio);
			switch (ret_val) {
			case -ENOENT:
				priv->ext_amp_gpio = NULL;
				break;
			default:
				dev_err(&pdev->dev, "Failed to get ext-amp-enable GPIO: %d\n",
					ret_val);
				/* fall through */
			case -EPROBE_DEFER:
				put_device(codec_dev);
				return ret_val;
			}
		}
	}

	put_device(codec_dev);

	log_quirks(&pdev->dev);

	if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) ||
	    (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) {
		/* fixup codec aif name */
		snprintf(byt_rt5651_codec_aif_name,
			sizeof(byt_rt5651_codec_aif_name),
			"%s", "rt5651-aif2");

		byt_rt5651_dais[dai_index].codec_dai_name =
			byt_rt5651_codec_aif_name;
	}

	if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) ||
	    (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) {
		/* fixup cpu dai name name */
		snprintf(byt_rt5651_cpu_dai_name,
			sizeof(byt_rt5651_cpu_dai_name),
			"%s", "ssp0-port");

		byt_rt5651_dais[dai_index].cpu_dai_name =
			byt_rt5651_cpu_dai_name;
	}

	if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) {
		priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3");
		if (IS_ERR(priv->mclk)) {
			ret_val = PTR_ERR(priv->mclk);
			dev_err(&pdev->dev,
				"Failed to get MCLK from pmc_plt_clk_3: %d\n",
				ret_val);
			/*
			 * Fall back to bit clock usage for -ENOENT (clock not
			 * available likely due to missing dependencies), bail
			 * for all other errors, including -EPROBE_DEFER
			 */
			if (ret_val != -ENOENT)
				return ret_val;
			byt_rt5651_quirk &= ~BYT_RT5651_MCLK_EN;
		}
	}

	if (byt_rt5651_quirk & BYT_RT5651_HP_LR_SWAPPED)
		hp_swapped = "-hp-swapped";
	else
		hp_swapped = "";

	snprintf(byt_rt5651_long_name, sizeof(byt_rt5651_long_name),
		 "bytcr-rt5651-%s-spk-%s-mic%s",
		 (byt_rt5651_quirk & BYT_RT5651_MONO_SPEAKER) ?
			"mono" : "stereo",
		 mic_name[BYT_RT5651_MAP(byt_rt5651_quirk)], hp_swapped);
	byt_rt5651_card.long_name = byt_rt5651_long_name;

	ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5651_card);

	if (ret_val) {
		dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
			ret_val);
		return ret_val;
	}
	platform_set_drvdata(pdev, &byt_rt5651_card);
	return ret_val;
}
Exemple #20
0
static int __init reboot_init(void)
{
	dmi_check_system(reboot_dmi_table);
	return 0;
}
Exemple #21
0
static int __init oaktrail_init(void)
{
	int ret;

	if (acpi_disabled) {
		pr_err("ACPI needs to be enabled for this driver to work!\n");
		return -ENODEV;
	}

	if (!force && !dmi_check_system(oaktrail_dmi_table)) {
		pr_err("Platform not recognized (You could try the module's force-parameter)");
		return -ENODEV;
	}

	ret = platform_driver_register(&oaktrail_driver);
	if (ret) {
		pr_warning("Unable to register platform driver\n");
		goto err_driver_reg;
	}

	oaktrail_device = platform_device_alloc(DRIVER_NAME, -1);
	if (!oaktrail_device) {
		pr_warning("Unable to allocate platform device\n");
		ret = -ENOMEM;
		goto err_device_alloc;
	}

	ret = platform_device_add(oaktrail_device);
	if (ret) {
		pr_warning("Unable to add platform device\n");
		goto err_device_add;
	}

	if (!acpi_video_backlight_support()) {
		ret = oaktrail_backlight_init();
		if (ret)
			goto err_backlight;

	} else
		pr_info("Backlight controlled by ACPI video driver\n");

	ret = oaktrail_rfkill_init();
	if (ret) {
		pr_warning("Setup rfkill failed\n");
		goto err_rfkill;
	}

	pr_info("Driver "DRIVER_VERSION" successfully loaded\n");
	return 0;

err_rfkill:
	oaktrail_backlight_exit();
err_backlight:
	platform_device_del(oaktrail_device);
err_device_add:
	platform_device_put(oaktrail_device);
err_device_alloc:
	platform_driver_unregister(&oaktrail_driver);
err_driver_reg:

	return ret;
}
Exemple #22
0
void __init dmi_check_skip_isa_align(void)
{
	dmi_check_system(can_skip_pciprobe_dmi_table);
}
Exemple #23
0
static int __init hdaps_init(void)
{
	int ret;

	if (!dmi_check_system(hdaps_whitelist)) {
		printk(KERN_WARNING "hdaps: supported laptop not found!\n");
		ret = -ENODEV;
		goto out;
	}

	if (!request_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS, "hdaps")) {
		ret = -ENXIO;
		goto out;
	}

	ret = platform_driver_register(&hdaps_driver);
	if (ret)
		goto out_region;

	pdev = platform_device_register_simple("hdaps", -1, NULL, 0);
	if (IS_ERR(pdev)) {
		ret = PTR_ERR(pdev);
		goto out_driver;
	}

	ret = sysfs_create_group(&pdev->dev.kobj, &hdaps_attribute_group);
	if (ret)
		goto out_device;

	hdaps_idev = input_allocate_device();
	if (!hdaps_idev) {
		ret = -ENOMEM;
		goto out_group;
	}

	/* initial calibrate for the input device */
	hdaps_calibrate();

	/* initialize the input class */
	hdaps_idev->name = "hdaps";
	hdaps_idev->cdev.dev = &pdev->dev;
	hdaps_idev->evbit[0] = BIT(EV_ABS);
	input_set_abs_params(hdaps_idev, ABS_X,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
	input_set_abs_params(hdaps_idev, ABS_Y,
			-256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);

	input_register_device(hdaps_idev);

	/* start up our timer for the input device */
	init_timer(&hdaps_timer);
	hdaps_timer.function = hdaps_mousedev_poll;
	hdaps_timer.expires = jiffies + HDAPS_POLL_PERIOD;
	add_timer(&hdaps_timer);

	printk(KERN_INFO "hdaps: driver successfully loaded.\n");
	return 0;

out_group:
	sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
out_device:
	platform_device_unregister(pdev);
out_driver:
	platform_driver_unregister(&hdaps_driver);
out_region:
	release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
out:
	printk(KERN_WARNING "hdaps: driver init failed (ret=%d)!\n", ret);
	return ret;
}
Exemple #24
0
acpi_status __init acpi_os_initialize(void)
{
	dmi_check_system(acpi_osl_dmi_table);
	return AE_OK;
}
Exemple #25
0
static __init int probe_bigsmp(void)
{
    dmi_check_system(bigsmp_dmi_table);
    return dmi_bigsmp;
}
static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
				const struct pci_device_id *id)
{
	unsigned char temp;

	if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
	    (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
		srvrworks_csb5_delay = 1;

	/* On some motherboards, it was reported that accessing the SMBus
	   caused severe hardware problems */
	if (dmi_check_system(piix4_dmi_blacklist)) {
		dev_err(&PIIX4_dev->dev,
			"Accessing the SMBus on this system is unsafe!\n");
		return -EPERM;
	}

	/* Don't access SMBus on IBM systems which get corrupted eeproms */
	if (dmi_check_system(piix4_dmi_ibm) &&
			PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
		dev_err(&PIIX4_dev->dev, "IBM system detected; this module "
			"may corrupt your serial eeprom! Refusing to load "
			"module!\n");
		return -EPERM;
	}

	/* Determine the address of the SMBus areas */
	if (force_addr) {
		piix4_smba = force_addr & 0xfff0;
		force = 0;
	} else {
		pci_read_config_word(PIIX4_dev, SMBBA, &piix4_smba);
		piix4_smba &= 0xfff0;
		if(piix4_smba == 0) {
			dev_err(&PIIX4_dev->dev, "SMBus base address "
				"uninitialized - upgrade BIOS or use "
				"force_addr=0xaddr\n");
			return -ENODEV;
		}
	}

	if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
		return -ENODEV;

	if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
		dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
			piix4_smba);
		return -EBUSY;
	}

	pci_read_config_byte(PIIX4_dev, SMBHSTCFG, &temp);

	/* If force_addr is set, we program the new address here. Just to make
	   sure, we disable the PIIX4 first. */
	if (force_addr) {
		pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp & 0xfe);
		pci_write_config_word(PIIX4_dev, SMBBA, piix4_smba);
		pci_write_config_byte(PIIX4_dev, SMBHSTCFG, temp | 0x01);
		dev_info(&PIIX4_dev->dev, "WARNING: SMBus interface set to "
			"new address %04x!\n", piix4_smba);
	} else if ((temp & 1) == 0) {
		if (force) {
			/* This should never need to be done, but has been
			 * noted that many Dell machines have the SMBus
			 * interface on the PIIX4 disabled!? NOTE: This assumes
			 * I/O space and other allocations WERE done by the
			 * Bios!  Don't complain if your hardware does weird
			 * things after enabling this. :') Check for Bios
			 * updates before resorting to this.
			 */
			pci_write_config_byte(PIIX4_dev, SMBHSTCFG,
					      temp | 1);
			dev_printk(KERN_NOTICE, &PIIX4_dev->dev,
				"WARNING: SMBus interface has been "
				"FORCEFULLY ENABLED!\n");
		} else {
			dev_err(&PIIX4_dev->dev,
				"Host SMBus controller not enabled!\n");
			release_region(piix4_smba, SMBIOSIZE);
			piix4_smba = 0;
			return -ENODEV;
		}
	}

	if (((temp & 0x0E) == 8) || ((temp & 0x0E) == 2))
		dev_dbg(&PIIX4_dev->dev, "Using Interrupt 9 for SMBus.\n");
	else if ((temp & 0x0E) == 0)
		dev_dbg(&PIIX4_dev->dev, "Using Interrupt SMI# for SMBus.\n");
	else
		dev_err(&PIIX4_dev->dev, "Illegal Interrupt configuration "
			"(or code out of date)!\n");

	pci_read_config_byte(PIIX4_dev, SMBREV, &temp);
	dev_info(&PIIX4_dev->dev,
		 "SMBus Host Controller at 0x%x, revision %d\n",
		 piix4_smba, temp);

	return 0;
}
static int __init ibm_rtl_init(void) {
    unsigned long ebda_addr, ebda_size;
    unsigned int ebda_kb;
    int ret = -ENODEV, i;

    if (force)
        pr_warn("module loaded by force\n");

    else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table))
        return -ENODEV;


    ebda_addr = get_bios_ebda();
    if (!ebda_addr) {
        RTL_DEBUG("no BIOS EBDA found\n");
        return -ENODEV;
    }

    ebda_map = ioremap(ebda_addr, 4);
    if (!ebda_map)
        return -ENOMEM;


    ebda_kb = ioread16(ebda_map);
    RTL_DEBUG("EBDA is %d kB\n", ebda_kb);

    if (ebda_kb == 0)
        goto out;

    iounmap(ebda_map);
    ebda_size = ebda_kb*1024;


    ebda_map = ioremap(ebda_addr, ebda_size);
    if (!ebda_map)
        return -ENOMEM;


    for (i = 0 ; i < ebda_size/sizeof(unsigned int); i++) {
        struct ibm_rtl_table __iomem * tmp;
        tmp = (struct ibm_rtl_table __iomem *) (ebda_map+i);
        if ((readq(&tmp->signature) & RTL_MASK) == RTL_SIGNATURE) {
            phys_addr_t addr;
            unsigned int plen;
            RTL_DEBUG("found RTL_SIGNATURE at %p\n", tmp);
            rtl_table = tmp;
            rtl_cmd_width = ioread8(&rtl_table->cmd_granularity);
            rtl_cmd_type = ioread8(&rtl_table->cmd_address_type);
            RTL_DEBUG("rtl_cmd_width = %u, rtl_cmd_type = %u\n",
                      rtl_cmd_width, rtl_cmd_type);
            addr = ioread32(&rtl_table->cmd_port_address);
            RTL_DEBUG("addr = %#llx\n", (unsigned long long)addr);
            plen = rtl_cmd_width/sizeof(char);
            rtl_cmd_addr = rtl_port_map(addr, plen);
            RTL_DEBUG("rtl_cmd_addr = %p\n", rtl_cmd_addr);
            if (!rtl_cmd_addr) {
                ret = -ENOMEM;
                break;
            }
            ret = rtl_setup_sysfs();
            break;
        }
    }

out:
    if (ret) {
        iounmap(ebda_map);
        rtl_port_unmap(rtl_cmd_addr);
    }

    return ret;
}