예제 #1
0
파일: chrp_pci.c 프로젝트: TitaniumBoy/lin
int __init
hydra_init(void)
{
	struct device_node *np;

	np = find_devices("mac-io");
	if (np == NULL || np->n_addrs == 0) {
		printk(KERN_WARNING "Warning: no mac-io found\n");
		return 0;
	}
	Hydra = ioremap(np->addrs[0].address, np->addrs[0].size);
	printk("Hydra Mac I/O at %x\n", np->addrs[0].address);
	out_le32(&Hydra->Feature_Control, (HYDRA_FC_SCC_CELL_EN |
					   HYDRA_FC_SCSI_CELL_EN |
					   HYDRA_FC_SCCA_ENABLE |
					   HYDRA_FC_SCCB_ENABLE |
					   HYDRA_FC_ARB_BYPASS |
					   HYDRA_FC_MPIC_ENABLE |
					   HYDRA_FC_SLOW_SCC_PCLK |
					   HYDRA_FC_MPIC_IS_MASTER));
	OpenPIC_Addr = &Hydra->OpenPIC;
	OpenPIC_InitSenses = hydra_openpic_initsenses;
	OpenPIC_NumInitSenses = sizeof(hydra_openpic_initsenses);
	return 1;
}
예제 #2
0
int main(int argc, char **argv)
{
        int rtn,i,pid;
        char cha,str[30];
	//rtn = log_progress("1");
	system("cd /Users/laurenceschenk/mini-src/mySrc/");
        rtn = shared_memory_attach();
        rtn = find_local();
	rtn = mk_daemon(argc,argv);	//must have this to write PID file
        rtn = shared_memory_attach();
        Mask = COLDIPOZZO_SEND | ROCCAMORICE_SEND | STARLIGHT_SEND | WEEHAWKEN_SEND ;
	rtn = find_devices();
	//rtn = log_progress("Main program starting....\n");
	system("cd /Users/laurenceschenk/mini-src/mySrc/coldipozzo");
	rtn = getuid();
	sprintf(str,"uid = %d",rtn);
	//rtn = log_progress(str);
	rtn = geteuid();
	sprintf(str,"euid = %d",rtn);
	//rtn = log_progress(str);
        while (1)
        {
		//rtn = log_progress("5");
                rtn =main_loop();
		//rtn = log_progress("6");
        }
        exit(0);
}
예제 #3
0
void __pmac register_backlight_controller(struct backlight_controller *ctrler,
					  void *data, char *type)
{
	struct device_node* bk_node;
	char *prop;
	int valid = 0;

	/* There's already a matching controller, bail out */
	if (backlighter != NULL)
		return;

	bk_node = find_devices("backlight");

#ifdef CONFIG_ADB_PMU
	/* Special case for the old PowerBook since I can't test on it */
	backlight_autosave = machine_is_compatible("AAPL,3400/2400")
		|| machine_is_compatible("AAPL,3500");
	if ((backlight_autosave
	     || machine_is_compatible("AAPL,PowerBook1998")
	     || machine_is_compatible("PowerBook1,1"))
	    && !strcmp(type, "pmu"))
		valid = 1;
#endif
	if (bk_node) {
		prop = get_property(bk_node, "backlight-control", NULL);
		if (prop && !strncmp(prop, type, strlen(type)))
			valid = 1;
	}
	if (!valid)
		return;
	backlighter = ctrler;
	backlighter_data = data;

	if (bk_node && !backlight_autosave)
		prop = get_property(bk_node, "bklt", NULL);
	else
		prop = NULL;
	if (prop) {
		backlight_level = ((*prop)+1) >> 1;
		if (backlight_level > BACKLIGHT_MAX)
			backlight_level = BACKLIGHT_MAX;
	}

#ifdef CONFIG_ADB_PMU
	if (backlight_autosave) {
		struct adb_request req;
		pmu_request(&req, NULL, 2, 0xd9, 0);
		while (!req.complete)
			pmu_poll();
		backlight_level = req.reply[0] >> 4;
	}
#endif
	acquire_console_sem();
	if (!backlighter->set_enable(1, backlight_level, data))
		backlight_enabled = 1;
	release_console_sem();

	printk(KERN_INFO "Registered \"%s\" backlight controller,"
	       "level: %d/15\n", type, backlight_level);
}
예제 #4
0
int __init
find_via_cuda(void)
{
    int err;
    struct adb_request req;

    if (vias != 0)
	return 1;
    vias = find_devices("via-cuda");
    if (vias == 0)
	return 0;
    if (vias->next != 0)
	printk(KERN_WARNING "Warning: only using 1st via-cuda\n");

#if 0
    { int i;

    printk("find_via_cuda: node = %p, addrs =", vias->node);
    for (i = 0; i < vias->n_addrs; ++i)
	printk(" %x(%x)", vias->addrs[i].address, vias->addrs[i].size);
    printk(", intrs =");
    for (i = 0; i < vias->n_intrs; ++i)
	printk(" %x", vias->intrs[i].line);
    printk("\n"); }
#endif

    if (vias->n_addrs != 1 || vias->n_intrs != 1) {
	printk(KERN_ERR "via-cuda: expecting 1 address (%d) and 1 interrupt (%d)\n",
	       vias->n_addrs, vias->n_intrs);
	if (vias->n_addrs < 1 || vias->n_intrs < 1)
	    return 0;
    }
    via = ioremap(vias->addrs->address, 0x2000);

    cuda_state = idle;
    sys_ctrler = SYS_CTRLER_CUDA;

    err = cuda_init_via();
    if (err) {
	printk(KERN_ERR "cuda_init_via() failed\n");
	via = NULL;
	return 0;
    }

    /* Clear and enable interrupts, but only on PPC. On 68K it's done  */
    /* for us by the main VIA driver in arch/m68k/mac/via.c        */

#ifndef CONFIG_MAC
    out_8(&via[IFR], 0x7f);	/* clear interrupts by writing 1s */
    out_8(&via[IER], IER_SET|SR_INT); /* enable interrupt from SR */
#endif

    /* enable autopoll */
    cuda_request(&req, NULL, 3, CUDA_PACKET, CUDA_AUTOPOLL, 1);
    while (!req.complete)
	cuda_poll();

    return 1;
}
예제 #5
0
int main(int argc, char *argv[])
{
	struct device_info dev[16];
	int i, opt, num, quiet = 0, mode = HCI;

	while ((opt = getopt_long(argc, argv, "+01qh", main_options, NULL)) != -1) {
		switch (opt) {
		case '0':
			mode = HCI;
			break;
		case '1':
			mode = HID;
			break;
		case 'q':
			quiet = 1;
			break;
		case 'h':
			usage();
			exit(0);
		default:
			exit(0);
		}
	}

	argc -= optind;
	argv += optind;
	optind = 0;

	usb_init();

	num = find_devices(mode, dev, sizeof(dev) / sizeof(dev[0]));
	if (num <= 0) {
		if (!quiet)
			fprintf(stderr, "No devices in %s mode found\n",
							mode ? "HCI" : "HID");
		exit(1);
	}

	for (i = 0; i < num; i++) {
		struct device_id *id = dev[i].id;

		if (!quiet)
			printf("Switching device %04x:%04x to %s mode ",
				id->vendor, id->product, mode ? "HID" : "HCI");
		fflush(stdout);

		if (id->func(&dev[i]) < 0) {
			if (!quiet)
				printf("failed (%s)\n", strerror(errno));
		} else {
			if (!quiet)
				printf("was successful\n");
		}
	}

	return 0;
}
예제 #6
0
int simplehal_supported(void)
{
	if (!connect_hal()) {
		return 0;
	} else {
		find_devices();
		return 1;
	}
}
예제 #7
0
void device_poll_thread() {
    adb_thread_setname("Device Poll");
    D("Created device thread");

    while (true) {
        find_devices();
        std::this_thread::sleep_for(1s);
    }
}
예제 #8
0
/* Fill the passed apm_info struct. */
int simplehal_read(int battery, apm_info *info)
{
	char *device;
	int i;

	/* Allow a battery that was not present before to appear. */
	if (battery > num_batteries)
		find_devices();

	info->battery_flags = 0;
	info->using_minutes = 0;

	info->ac_line_status = 0;
	for (i = 0 ; i < num_ac_adapters && !info->ac_line_status ; i++)
		info->ac_line_status = (get_hal_bool(ac_adapters[i], "ac_adapter.present", 0) == 1);

	if (battery > num_batteries) {
		info->battery_percentage = 0;
		info->battery_time = 0;
		info->battery_status = BATTERY_STATUS_ABSENT;
		return 0;
	} else {
		device = batteries[battery-1];
	}

	if (get_hal_bool(device, "battery.present", 0) != 1) {
		info->battery_percentage = 0;
		info->battery_time = 0;
		info->battery_status = BATTERY_STATUS_ABSENT;
		return 0;
	}

	/* remaining_time and charge_level.percentage are not a mandatory
	 * keys, so if not present, -1 will be returned */
	info->battery_time = get_hal_int(device, "battery.remaining_time", 1);
	info->battery_percentage = get_hal_int(device, "battery.charge_level.percentage", 1);
	if (get_hal_bool(device, "battery.rechargeable.is_discharging", 0) == 1) {
		info->battery_status = BATTERY_STATUS_CHARGING;
		/* charge_level.warning and charge_level.low are not
		 * required to be available; this is good enough */
		if (info->battery_percentage < 1)
			info->battery_status = BATTERY_STATUS_CRITICAL;
		else if (info->battery_percentage < 10)
			info->battery_status = BATTERY_STATUS_LOW;
	} else if (info->ac_line_status &&
		 get_hal_bool(device, "battery.rechargeable.is_charging", 0) == 1) {
		info->battery_status = BATTERY_STATUS_CHARGING;
		info->battery_flags = info->battery_flags | BATTERY_FLAGS_CHARGING;
	} else if (info->ac_line_status) {
		/* Must be fully charged. */
		info->battery_status = BATTERY_STATUS_HIGH;
	} else {
		fprintf(stderr, "unknown battery state\n");
	}

	return 0;
}
예제 #9
0
  /**
   * Scan the usb device that have given vendor and product id.
   * @return positive number of devices connected.<br>-1 on failure
   **/
  int scan()
  {
    devices = find_devices(0x0403,0x6001);

    if( devices.empty() ) return -1;
    scanned = true;
    retrieved = false;
    return devices.size();
  }
예제 #10
0
void
scsi_curio_dbdma_init(int unit)
{
	device_node_t	*curio;

	scsi_curio_dbdma_commands = dbdma_alloc(2);

	curio = find_devices("53c94");
	curio_chan = (dbdma_regmap_t *) POWERMAC_IO(curio->addrs[1].address);
}
예제 #11
0
unsigned char *
find_property(const char *device, const char *propname, unsigned long *size)
{
	device_node_t	*node;

	if ((node = find_devices(device)) == NULL)
		return	NULL;

	return get_property(node, propname, size);
}
예제 #12
0
/*
 * Calibrate the decrementer register using VIA timer 1.
 * This is used both on powermacs and CHRP machines.
 */
__initfunc(int via_calibrate_decr(void))
{
	struct device_node *vias;
	volatile unsigned char *via;
	int count = VIA_TIMER_FREQ_6 / HZ;
	unsigned int dstart, dend;

	vias = find_devices("via-cuda");
	if (vias == 0)
		vias = find_devices("via-pmu");
	if (vias == 0)
		vias = find_devices("via");
	if (vias == 0 || vias->n_addrs == 0)
		return 0;
	via = (volatile unsigned char *)
		ioremap(vias->addrs[0].address, vias->addrs[0].size);

	/* set timer 1 for continuous interrupts */
	out_8(&via[ACR], (via[ACR] & ~T1MODE) | T1MODE_CONT);
	/* set the counter to a small value */
	out_8(&via[T1CH], 2);
	/* set the latch to `count' */
	out_8(&via[T1LL], count);
	out_8(&via[T1LH], count >> 8);
	/* wait until it hits 0 */
	while ((in_8(&via[IFR]) & T1_INT) == 0)
		;
	dstart = get_dec();
	/* clear the interrupt & wait until it hits 0 again */
	in_8(&via[T1CL]);
	while ((in_8(&via[IFR]) & T1_INT) == 0)
		;
	dend = get_dec();

	decrementer_count = (dstart - dend) / 6;
	count_period_num = 60;
	count_period_den = decrementer_count * 6 * HZ / 100000;

	printk(KERN_INFO "via_calibrate_decr: decrementer_count = %u (%u ticks)\n",
	       decrementer_count, dstart - dend);

	return 1;
}
예제 #13
0
int main(int argc, char *argv[])
{
	struct device_info dev[16];
	int i, opt, num, quiet = 0;

	while ((opt = getopt_long(argc, argv, "+qh", main_options, NULL)) != -1) {
		switch (opt) {
		case 'q':
			quiet = 1;
			break;
		case 'h':
			usage();
			exit(0);
		default:
			exit(0);
		}
	}

	argc -= optind;
	argv += optind;
	optind = 0;

	usb_init();

	num = find_devices(dev, sizeof(dev) / sizeof(dev[0]));
	if (num <= 0) {
		if (!quiet)
			fprintf(stderr, "No Babel devices found\n");
		exit(1);
	}

	for (i = 0; i < num; i++) {
		struct device_id *id = dev[i].id;
		int err;

		if (!quiet)
			printf("Switching device %04x:%04x ",
						id->vendor, id->product);
		fflush(stdout);

		err = id->func(&dev[i], argc, argv);
		if (err < 0) {
			if (!quiet)
				printf("failed (%s)\n", strerror(-err));
		} else {
			if (!quiet)
				printf("was successful\n");
		}
	}

	return 0;
}
예제 #14
0
int main(int argc, char** argv)
{
  std::vector<struct usb_device *> devices;

  devices = find_devices(0x0403,0x6001);
  if (devices.empty()) {
    std::cout << "not found!!!" << std::endl;
    return -1;
  }
  std::cout << devices.size() << " device(s) found." << std::endl;

  int ret_val=0;
  for( unsigned int i=0; i<devices.size(); i++ ) 
  {
    std::cout << std::endl;
    std::cout << "Device #" << i  << std::endl;

    struct usb_device *dev = devices[i];
    usb_dev_handle *h = usb_open(dev);
    if( h < 0 ) {
      std::cerr << "failed to open usb device." << std::endl;
      std::cerr << "do with sudo." << std::endl;
    }
  
    char buff[128];
    int n;
    n = usb_get_string_simple(h, dev->descriptor.iManufacturer, buff, 128);
    if (n < 0) {
      std::cerr << "something is going wrong. do it again with sudo." << std::endl;
      ret_val = -1;
      continue;
    }
    std::cout << "  Manufacturer : " << std::string(buff) << std::endl;
  
    n = usb_get_string_simple(h, dev->descriptor.iProduct, buff, 128);
    if (n < 0) {
      std::cerr << "something is going wrong. do it again with sudo." << std::endl;
      ret_val = -1;
      continue;
    }
    std::cout << "  Product      : " << std::string(buff) << std::endl;

    n = usb_get_string_simple(h, dev->descriptor.iSerialNumber, buff, 128);
    if (n < 0) { 
      std::cerr << "something is going wrong. do it again with sudo." << std::endl;
      ret_val = -1;
      continue;
    }
    std::cout << "  Serial Number: " << std::string(buff) << std::endl;
  } 
  return ret_val;
}  
예제 #15
0
파일: backlight.c 프로젝트: ivucica/linux
int pmac_has_backlight_type(const char *type)
{
	struct device_node* bk_node = find_devices("backlight");

	if (bk_node) {
		const char *prop = get_property(bk_node,
				"backlight-control", NULL);
		if (prop && strncmp(prop, type, strlen(type)) == 0)
			return 1;
	}

	return 0;
}
예제 #16
0
int
chips_probe(caddr_t addr)
{
	int	i;

	for (i = 0; chips_names[i]; i++)
		if (chips_node = find_devices(chips_names[i])) {
			regBase = regBasePhys = (volatile unsigned char *)
				chips_node->addrs[0].address + CHIPS_REG_OFFSET;
			return 1;
		}

	return 0;
}
예제 #17
0
static int __init pmac_declare_of_platform_devices(void)
{
	struct device_node *np;

	np = find_devices("u3");
	if (np) {
		for (np = np->child; np != NULL; np = np->sibling)
			if (strncmp(np->name, "i2c", 3) == 0) {
				of_platform_device_create(np, "u3-i2c");
				break;
			}
	}

	return 0;
}
예제 #18
0
파일: vio.c 프로젝트: mrtos/Logitech-Revue
/**
 * vio_bus_init: - Initialize the virtual IO bus
 */
static int __init vio_bus_init(void)
{
	int err;
	struct device_node *node_vroot;

#ifdef CONFIG_PPC_ISERIES
	if (firmware_has_feature(FW_FEATURE_ISERIES)) {
		iommu_vio_init();
		vio_bus_device.iommu_table = &vio_iommu_table;
		iSeries_vio_dev = &vio_bus_device.dev;
	}
#endif

	err = bus_register(&vio_bus_type);
	if (err) {
		printk(KERN_ERR "failed to register VIO bus\n");
		return err;
	}

	/*
	 * The fake parent of all vio devices, just to give us
	 * a nice directory
	 */
	err = device_register(&vio_bus_device.dev);
	if (err) {
		printk(KERN_WARNING "%s: device_register returned %i\n",
				__FUNCTION__, err);
		return err;
	}

	node_vroot = find_devices("vdevice");
	if (node_vroot) {
		struct device_node *of_node;

		/*
		 * Create struct vio_devices for each virtual device in
		 * the device tree. Drivers will associate with them later.
		 */
		for (of_node = node_vroot->child; of_node != NULL;
				of_node = of_node->sibling) {
			printk(KERN_DEBUG "%s: processing %p\n",
					__FUNCTION__, of_node);
			vio_register_device_node(of_node);
		}
	}

	return 0;
}
예제 #19
0
int __init
tas_init(int driver_id, const char *driver_name)
{
	u32* paddr;

	printk(KERN_INFO "tas driver [%s])\n", driver_name);

	tas_node = find_devices("deq");
	if (tas_node == NULL)
		return -ENODEV;
	paddr = (u32 *)get_property(tas_node, "i2c-address", NULL);
	if (paddr) {
		tas_i2c_address = (*paddr) >> 1;
		printk(KERN_INFO "using i2c address: 0x%x from device-tree\n",
				tas_i2c_address);
	} else    
예제 #20
0
QVector<CommPortPtr>
Serial::myListCommPorts(QString &err)
{
    static const int MAX_DEVICES = 100;
    (void) err;
    QVector<CommPortPtr> result;
    char *devices[MAX_DEVICES];
    int devcnt = find_devices(devices, MAX_DEVICES);
    if (devcnt == 0)
        err = "No serial devices found.";
    for (int i = 0; i < devcnt; ++i) {
        result.append(CommPortPtr(new Serial(devices[i])));
        free(devices[i]);
    }
    return result;
}
예제 #21
0
void __pmac pmac_show_cpuinfo(struct seq_file *m)
{
	struct device_node *np;
	char *pp;
	int plen;
	char* mbname;
	int mbmodel = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
					PMAC_MB_INFO_MODEL, 0);
	unsigned int mbflags = pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL,
						 PMAC_MB_INFO_FLAGS, 0);

	if (pmac_call_feature(PMAC_FTR_GET_MB_INFO, NULL, PMAC_MB_INFO_NAME,
			      (long)&mbname) != 0)
		mbname = "Unknown";
	
	/* find motherboard type */
	seq_printf(m, "machine\t\t: ");
	np = find_devices("device-tree");
	if (np != NULL) {
		pp = (char *) get_property(np, "model", NULL);
		if (pp != NULL)
			seq_printf(m, "%s\n", pp);
		else
			seq_printf(m, "PowerMac\n");
		pp = (char *) get_property(np, "compatible", &plen);
		if (pp != NULL) {
			seq_printf(m, "motherboard\t:");
			while (plen > 0) {
				int l = strlen(pp) + 1;
				seq_printf(m, " %s", pp);
				plen -= l;
				pp += l;
			}
			seq_printf(m, "\n");
		}
	} else
		seq_printf(m, "PowerMac\n");

	/* print parsed model */
	seq_printf(m, "detected as\t: %d (%s)\n", mbmodel, mbname);
	seq_printf(m, "pmac flags\t: %08x\n", mbflags);

	/* Indicate newworld */
	seq_printf(m, "pmac-generation\t: NewWorld\n");
}
예제 #22
0
static int __init
init_airport(void)
{
	struct device_node* airport_node;

	printk(KERN_DEBUG "%s\n", version);

	MOD_INC_USE_COUNT;

	/* Lookup card in device tree */
	airport_node = find_devices("radio");
	if (airport_node && !strcmp(airport_node->parent->name, "mac-io"))
		airport_dev = airport_attach(airport_node);

	MOD_DEC_USE_COUNT;

	return airport_dev ? 0 : -ENODEV;
}
예제 #23
0
int __init
tas_init(int driver_id, const char *driver_name)
{
	u32* paddr;

	printk(KERN_INFO "tas driver [%s])\n", driver_name);

#ifndef CONFIG_I2C_KEYWEST
	request_module("i2c-keywest");
#endif
	tas_node = find_devices("deq");
	if (tas_node == NULL)
		return -ENODEV;
	paddr = (u32 *)get_property(tas_node, "i2c-address", NULL);
	if (paddr) {
		tas_i2c_address = (*paddr) >> 1;
		printk(KERN_INFO "using i2c address: 0x%x from device-tree\n",
				tas_i2c_address);
	} else    
예제 #24
0
int __init
hydra_init(void)
{
	struct device_node *np;

	np = find_devices("mac-io");
	if (np == NULL || np->n_addrs == 0)
		return 0;
	Hydra = ioremap(np->addrs[0].address, np->addrs[0].size);
	printk("Hydra Mac I/O at %x\n", np->addrs[0].address);
	out_le32(&Hydra->Feature_Control, (HYDRA_FC_SCC_CELL_EN |
					   HYDRA_FC_SCSI_CELL_EN |
					   HYDRA_FC_SCCA_ENABLE |
					   HYDRA_FC_SCCB_ENABLE |
					   HYDRA_FC_ARB_BYPASS |
					   HYDRA_FC_MPIC_ENABLE |
					   HYDRA_FC_SLOW_SCC_PCLK |
					   HYDRA_FC_MPIC_IS_MASTER));
	return 1;
}
예제 #25
0
static int enable_all_gpus(Options *op, XConfigPtr config,
                           XConfigLayoutPtr layout)
{
    DevicesPtr pDevices;
    int i;

    pDevices = find_devices(op);
    if (!pDevices) {
        nv_error_msg("Unable to determine number of GPUs in system; cannot "
                     "honor '--enable-all-gpus' option.");
        return FALSE;
    }
    
    /* free all existing X screens, monitors, devices, and adjacencies */
    
    xconfigFreeScreenList(&config->screens);
    xconfigFreeDeviceList(&config->devices);
    xconfigFreeMonitorList(&config->monitors);
    xconfigFreeAdjacencyList(&layout->adjacencies);

    /* add N new screens; this will also add device and monitor sections */
    
    for (i = 0; i < pDevices->nDevices; i++) {
        xconfigGenerateAddScreen(config,
                                 pDevices->devices[i].dev.bus,
                                 pDevices->devices[i].dev.domain,
                                 pDevices->devices[i].dev.slot,
                                 pDevices->devices[i].name, i,
                                 "nvidia", "NVIDIA Corporation");
    }
    
    free_devices(pDevices);

    /* create adjacencies for the layout */
    
    create_adjacencies(op, config, layout);

    return TRUE;
    
} /* enable_all_gpus() */
예제 #26
0
static int __init
anslcd_init(void)
{
	int a;
	int retval;
	struct device_node* node;

	node = find_devices("lcd");
	if (!node || !node->parent)
		return -ENODEV;
	if (strcmp(node->parent->name, "gc"))
		return -ENODEV;

	anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
	
	retval = misc_register(&anslcd_dev);
	if(retval < 0){
		printk(KERN_INFO "LCD: misc_register failed\n");
		iounmap(anslcd_ptr);
		return retval;
	}

#ifdef DEBUG
	printk(KERN_DEBUG "LCD: init\n");
#endif

	anslcd_write_byte_ctrl ( 0x38 );
	anslcd_write_byte_ctrl ( 0x0c );
	anslcd_write_byte_ctrl ( 0x06 );
	anslcd_write_byte_ctrl ( 0x01 );
	anslcd_write_byte_ctrl ( 0x02 );
	for(a=0;a<80;a++) {
		anslcd_write_byte_data(anslcd_logo[a]);
	}
	return 0;
}
예제 #27
0
int __init
hydra_init(void)
{
	struct device_node *np;
	struct resource r;

	np = find_devices("mac-io");
	if (np == NULL || of_address_to_resource(np, 0, &r))
		return 0;
	Hydra = ioremap(r.start, r.end-r.start);
	printk("Hydra Mac I/O at %lx\n", r.start);
	printk("Hydra Feature_Control was %x",
	       in_le32(&Hydra->Feature_Control));
	out_le32(&Hydra->Feature_Control, (HYDRA_FC_SCC_CELL_EN |
					   HYDRA_FC_SCSI_CELL_EN |
					   HYDRA_FC_SCCA_ENABLE |
					   HYDRA_FC_SCCB_ENABLE |
					   HYDRA_FC_ARB_BYPASS |
					   HYDRA_FC_MPIC_ENABLE |
					   HYDRA_FC_SLOW_SCC_PCLK |
					   HYDRA_FC_MPIC_IS_MASTER));
	printk(", now %x\n", in_le32(&Hydra->Feature_Control));
	return 1;
}
예제 #28
0
void* device_poll_thread(void* _bridge) {
  bridge = (struct dll_bridge *)_bridge;
  D("Created device thread\n");

  int i = 0;
  while(1) {
    if (notify_should_kill()) {
      D("Cleaned in timer handler\n");
      return NULL;
    }

    if(i % 10 == 0) {
      D("In the if-statement");
      find_devices();
      i = 1;
    } else {
      i++;
    }

    adb_sleep_ms(100);
  }

  return NULL;
}
예제 #29
0
int __pmac
pmac_show_cpuinfo(struct seq_file *m)
{
	struct device_node *np;
	char *pp;
	int plen;

	/* find motherboard type */
	seq_printf(m, "machine\t\t: ");
	np = find_devices("device-tree");
	if (np != NULL) {
		pp = (char *) get_property(np, "model", NULL);
		if (pp != NULL)
			seq_printf(m, "%s\n", pp);
		else
			seq_printf(m, "PowerMac\n");
		pp = (char *) get_property(np, "compatible", &plen);
		if (pp != NULL) {
			seq_printf(m, "motherboard\t:");
			while (plen > 0) {
				int l = strlen(pp) + 1;
				seq_printf(m, " %s", pp);
				plen -= l;
				pp += l;
			}
			seq_printf(m, "\n");
		}
	} else
		seq_printf(m, "PowerMac\n");

	/* find l2 cache info */
	np = find_devices("l2-cache");
	if (np == 0)
		np = find_type_devices("cache");
	if (np != 0) {
		unsigned int *ic = (unsigned int *)
			get_property(np, "i-cache-size", NULL);
		unsigned int *dc = (unsigned int *)
			get_property(np, "d-cache-size", NULL);
		seq_printf(m, "L2 cache\t:");
		has_l2cache = 1;
		if (get_property(np, "cache-unified", NULL) != 0 && dc) {
			seq_printf(m, " %dK unified", *dc / 1024);
		} else {
			if (ic)
				seq_printf(m, " %dK instruction", *ic / 1024);
			if (dc)
				seq_printf(m, "%s %dK data",
					   (ic? " +": ""), *dc / 1024);
		}
		pp = get_property(np, "ram-type", NULL);
		if (pp)
			seq_printf(m, " %s", pp);
		seq_printf(m, "\n");
	}

	/* find ram info */
	np = find_devices("memory");
	if (np != 0) {
		int n;
		struct reg_property *reg = (struct reg_property *)
			get_property(np, "reg", &n);
		
		if (reg != 0) {
			unsigned long total = 0;

			for (n /= sizeof(struct reg_property); n > 0; --n)
				total += (reg++)->size;
			seq_printf(m, "memory\t\t: %luMB\n", total >> 20);
		}
예제 #30
0
__initfunc(void
pmac_pic_init(void))
{
        int i;
        struct device_node *irqctrler;
        volatile struct pmac_irq_hw *addr;
	int second_irq;

	/* We first try to detect Apple's new Core99 chipset, since mac-io
	 * is quite different on those machines and contains an IBM MPIC2.
	 */
	irqctrler = find_type_devices("open-pic");
	if (irqctrler != NULL) {
	    printk("PowerMac using OpenPIC irq controller\n");
	    if (irqctrler->n_addrs > 0) {
#ifdef CONFIG_XMON
		struct device_node* pswitch;
#endif /* CONFIG_XMON */	
		OpenPIC = (volatile struct OpenPIC *)
			ioremap(irqctrler->addrs[0].address,
			irqctrler->addrs[0].size);
		for ( i = 0 ; i < NR_IRQS ; i++ ) {
		    irq_desc[i].ctl = &pmac_open_pic;
		    irq_desc[i].level = 0;
		}
		openpic_init(1);
		has_openpic = 1;
#ifdef CONFIG_XMON
		pswitch = find_devices("programmer-switch");
		if (pswitch && pswitch->n_intrs)
			request_irq(pswitch->intrs[0].line, xmon_irq, 0,	
				"NMI - XMON", 0);
#endif	/* CONFIG_XMON */
		return;
	    }
	    irqctrler = NULL;
	}

	/*
	 * G3 powermacs and 1999 G3 PowerBooks have 64 interrupts,
	 * 1998 G3 Series PowerBooks have 128, 
	 * other powermacs have 32.
	 * The combo ethernet/modem card for the Powerstar powerbooks
	 * (2400/3400/3500, ohare based) has a second ohare chip
	 * effectively making a total of 64.
	 */
	max_irqs = max_real_irqs = 32;
	irqctrler = find_devices("mac-io");
	if (irqctrler)
	{
		max_real_irqs = 64;
		if (irqctrler->next)
			max_irqs = 128;
		else
			max_irqs = 64;
	}
	for ( i = 0; i < max_real_irqs ; i++ )
		irq_desc[i].ctl = &pmac_pic;

	/* get addresses of first controller */
	if (irqctrler) {
		if  (irqctrler->n_addrs > 0) {
			addr = ioremap(irqctrler->addrs[0].address, 0x40);
			addr += 2;
			for (i = 0; i < 2; ++i, --addr)
				pmac_irq_hw[i] = addr;
		}
		
		/* get addresses of second controller */
		irqctrler = irqctrler->next;
		if (irqctrler && irqctrler->n_addrs > 0) {
			addr = ioremap(irqctrler->addrs[0].address, 0x40);
			addr += 2;
			for (i = 2; i < 4; ++i, --addr)
				pmac_irq_hw[i] = addr;
		}
	}

	/* PowerBooks 3400 and 3500 can have a second controller in a second
	   ohare chip, on the combo ethernet/modem card */
	if (machine_is_compatible("AAPL,3400/2400")
	     || machine_is_compatible("AAPL,3500"))
		enable_second_ohare();

	/* disable all interrupts in all controllers */
	for (i = 0; i * 32 < max_irqs; ++i)
		out_le32(&pmac_irq_hw[i]->enable, 0);
	
	/* get interrupt line of secondary interrupt controller */
	if (irqctrler) {
		second_irq = irqctrler->intrs[0].line;
		printk(KERN_INFO "irq: secondary controller on irq %d\n",
			(int)second_irq);
		if (device_is_compatible(irqctrler, "gatwick"))
			pmac_fix_gatwick_interrupts(irqctrler, max_real_irqs);
		request_irq( second_irq, gatwick_action, SA_INTERRUPT,
			     "interrupt cascade", 0 );
	}
	for (i = max_real_irqs; i < max_irqs; i++)
		irq_desc[i].ctl = &gatwick_pic;
	printk("System has %d possible interrupts\n", max_irqs);
	if (max_irqs != max_real_irqs)
		printk(KERN_DEBUG "%d interrupts on main controller\n",
			max_real_irqs);

#ifdef CONFIG_XMON
	request_irq(20, xmon_irq, 0, "NMI - XMON", 0);
#endif	/* CONFIG_XMON */
}