Lines Matching refs:smu
16 * - maybe avoid some data copies with i2c by directly using the smu cmd
48 #include <asm/smu.h>
100 static struct smu_device *smu;
115 if (list_empty(&smu->cmd_list))
119 cmd = list_entry(smu->cmd_list.next, struct smu_cmd, link);
120 smu->cmd_cur = cmd;
132 smu->cmd_buf->cmd = cmd->cmd;
133 smu->cmd_buf->length = cmd->data_len;
134 memcpy(smu->cmd_buf->data, cmd->data_buf, cmd->data_len);
137 faddr = (unsigned long)smu->cmd_buf;
138 fend = faddr + smu->cmd_buf->length + 2;
151 if (smu->broken_nap)
158 writel(smu->cmd_buf_abs, smu->db_buf);
161 pmac_do_feature_call(PMAC_FTR_WRITE_GPIO, NULL, smu->doorbell, 4);
177 spin_lock_irqsave(&smu->lock, flags);
179 gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, smu->doorbell);
181 spin_unlock_irqrestore(&smu->lock, flags);
185 cmd = smu->cmd_cur;
186 smu->cmd_cur = NULL;
200 faddr = (unsigned long)smu->cmd_buf;
205 if (ack != smu->cmd_buf->cmd) {
207 ack, smu->cmd_buf->cmd);
210 reply_len = rc == 0 ? smu->cmd_buf->length : 0;
220 memcpy(cmd->reply_buf, smu->cmd_buf->data, reply_len);
232 if (smu->broken_nap)
237 spin_unlock_irqrestore(&smu->lock, flags);
271 if (smu == NULL)
278 spin_lock_irqsave(&smu->lock, flags);
279 list_add_tail(&cmd->link, &smu->cmd_list);
280 if (smu->cmd_cur == NULL)
282 spin_unlock_irqrestore(&smu->lock, flags);
284 if (!smu_irq_inited || smu->db_irq == NO_IRQ)
327 if (smu == NULL)
330 gpio = pmac_do_feature_call(PMAC_FTR_READ_GPIO, NULL, smu->doorbell);
332 smu_db_intr(smu->db_irq, smu);
388 if (smu == NULL)
415 if (smu == NULL)
439 if (smu == NULL)
455 if (smu == NULL)
469 return smu != NULL;
480 np = of_find_node_by_type(NULL, "smu");
492 smu = alloc_bootmem(sizeof(struct smu_device));
494 spin_lock_init(&smu->lock);
495 INIT_LIST_HEAD(&smu->cmd_list);
496 INIT_LIST_HEAD(&smu->cmd_i2c_list);
497 smu->of_node = np;
498 smu->db_irq = NO_IRQ;
499 smu->msg_irq = NO_IRQ;
504 smu->cmd_buf_abs = (u32)smu_cmdbuf_abs;
505 smu->cmd_buf = (struct smu_cmd_buf *)abs_to_virt(smu_cmdbuf_abs);
507 smu->db_node = of_find_node_by_name(NULL, "smu-doorbell");
508 if (smu->db_node == NULL) {
513 data = of_get_property(smu->db_node, "reg", NULL);
524 smu->doorbell = *data;
525 if (smu->doorbell < 0x50)
526 smu->doorbell += 0x50;
528 /* Now look for the smu-interrupt GPIO */
530 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
531 if (smu->msg_node == NULL)
533 data = of_get_property(smu->msg_node, "reg", NULL);
535 of_node_put(smu->msg_node);
536 smu->msg_node = NULL;
539 smu->msg = *data;
540 if (smu->msg < 0x50)
541 smu->msg += 0x50;
548 smu->db_buf = ioremap(0x8000860c, 0x1000);
549 if (smu->db_buf == NULL) {
556 smu->broken_nap = pmac_get_uninorth_variant() < 4;
557 if (smu->broken_nap)
564 if (smu->msg_node)
565 of_node_put(smu->msg_node);
567 of_node_put(smu->db_node);
569 free_bootmem((unsigned long)smu, sizeof(struct smu_device));
570 smu = NULL;
579 if (!smu)
582 init_timer(&smu->i2c_timer);
583 smu->i2c_timer.function = smu_i2c_retry;
584 smu->i2c_timer.data = (unsigned long)smu;
586 if (smu->db_node) {
587 smu->db_irq = irq_of_parse_and_map(smu->db_node, 0);
588 if (smu->db_irq == NO_IRQ)
589 printk(KERN_ERR "smu: failed to map irq for node %s\n",
590 smu->db_node->full_name);
592 if (smu->msg_node) {
593 smu->msg_irq = irq_of_parse_and_map(smu->msg_node, 0);
594 if (smu->msg_irq == NO_IRQ)
595 printk(KERN_ERR "smu: failed to map irq for node %s\n",
596 smu->msg_node->full_name);
603 if (smu->db_irq != NO_IRQ) {
604 if (request_irq(smu->db_irq, smu_db_intr,
605 IRQF_SHARED, "SMU doorbell", smu) < 0) {
608 smu->db_irq);
609 smu->db_irq = NO_IRQ;
613 if (smu->msg_irq != NO_IRQ) {
614 if (request_irq(smu->msg_irq, smu_msg_intr,
615 IRQF_SHARED, "SMU message", smu) < 0) {
618 smu->msg_irq);
619 smu->msg_irq = NO_IRQ;
639 for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
640 if (of_device_is_compatible(np, "smu-sensors"))
641 of_platform_device_create(np, "smu-sensors",
642 &smu->of_dev->dev);
650 if (!smu)
652 smu->of_dev = dev;
666 .type = "smu",
674 .name = "smu",
699 if (!smu)
701 return smu->of_dev;
731 spin_lock_irqsave(&smu->lock, flags);
732 smu->cmd_i2c_cur = NULL;
737 if (!list_empty(&smu->cmd_i2c_list)) {
741 newcmd = list_entry(smu->cmd_i2c_list.next,
743 smu->cmd_i2c_cur = newcmd;
746 /* Queue with low level smu */
747 list_add_tail(&cmd->scmd.link, &smu->cmd_list);
748 if (smu->cmd_cur == NULL)
751 spin_unlock_irqrestore(&smu->lock, flags);
762 struct smu_i2c_cmd *cmd = smu->cmd_i2c_cur;
797 BUG_ON(cmd != smu->cmd_i2c_cur);
803 mod_timer(&smu->i2c_timer, jiffies + msecs_to_jiffies(5));
831 if (smu == NULL)
889 spin_lock_irqsave(&smu->lock, flags);
890 if (smu->cmd_i2c_cur == NULL) {
891 smu->cmd_i2c_cur = cmd;
892 list_add_tail(&cmd->scmd.link, &smu->cmd_list);
893 if (smu->cmd_cur == NULL)
896 list_add_tail(&cmd->link, &smu->cmd_i2c_list);
897 spin_unlock_irqrestore(&smu->lock, flags);
962 DPRINTK("SMU: Query partition infos ... (irq=%d)\n", smu->db_irq);
1005 if (prom_add_property(smu->of_node, prop)) {
1026 if (!smu)
1041 part = of_get_property(smu->of_node, pname, size);
1327 MISC_DYNAMIC_MINOR, "smu", &smu_device_fops
1332 if (!smu)