2 * Copyright (C) 2001-2004 by David Brownell
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /* this file is part of ehci-hcd.c */
21 /*-------------------------------------------------------------------------*/
24 * EHCI Root Hub ... the nonsharable stuff
26 * Registers don't need cpu_to_le32, that happens transparently
29 /*-------------------------------------------------------------------------*/
31 #ifdef CONFIG_USB_PERSIST
33 static int ehci_hub_control(
42 /* After a power loss, ports that were owned by the companion must be
43 * reset so that the companion can still own them.
45 static void ehci_handover_companion_ports(struct ehci_hcd *ehci)
51 struct usb_hcd *hcd = ehci_to_hcd(ehci);
53 if (!ehci->owned_ports)
56 /* Give the connections some time to appear */
59 port = HCS_N_PORTS(ehci->hcs_params);
61 if (test_bit(port, &ehci->owned_ports)) {
62 reg = &ehci->regs->port_status[port];
63 status = ehci_readl(ehci, reg);
65 /* Port already owned by companion? */
66 if (status & PORT_OWNER)
67 clear_bit(port, &ehci->owned_ports);
69 ehci_hub_control(hcd, SetPortFeature,
70 USB_PORT_FEAT_RESET, port + 1,
75 if (!ehci->owned_ports)
77 msleep(90); /* Wait for resets to complete */
79 port = HCS_N_PORTS(ehci->hcs_params);
81 if (test_bit(port, &ehci->owned_ports)) {
82 ehci_hub_control(hcd, GetPortStatus,
84 (char *) &buf, sizeof(buf));
86 /* The companion should now own the port,
87 * but if something went wrong the port must not
90 reg = &ehci->regs->port_status[port];
91 status = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
92 if (status & PORT_OWNER)
93 ehci_writel(ehci, status | PORT_CSC, reg);
95 ehci_dbg(ehci, "failed handover port %d: %x\n",
97 ehci_writel(ehci, status & ~PORT_PE, reg);
102 ehci->owned_ports = 0;
105 #else /* CONFIG_USB_PERSIST */
107 static inline void ehci_handover_companion_ports(struct ehci_hcd *ehci)
114 static int ehci_bus_suspend (struct usb_hcd *hcd)
116 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
120 ehci_dbg(ehci, "suspend root hub\n");
122 if (time_before (jiffies, ehci->next_statechange))
125 port = HCS_N_PORTS (ehci->hcs_params);
126 spin_lock_irq (&ehci->lock);
128 /* stop schedules, clean any completed work */
129 if (HC_IS_RUNNING(hcd->state)) {
131 hcd->state = HC_STATE_QUIESCING;
133 ehci->command = ehci_readl(ehci, &ehci->regs->command);
135 ehci->reclaim_ready = 1;
138 /* Unlike other USB host controller types, EHCI doesn't have
139 * any notion of "global" or bus-wide suspend. The driver has
140 * to manually suspend all the active unsuspended ports, and
141 * then manually resume them in the bus_resume() routine.
143 ehci->bus_suspended = 0;
144 ehci->owned_ports = 0;
146 u32 __iomem *reg = &ehci->regs->port_status [port];
147 u32 t1 = ehci_readl(ehci, reg) & ~PORT_RWC_BITS;
150 /* keep track of which ports we suspend */
152 set_bit(port, &ehci->owned_ports);
153 else if ((t1 & PORT_PE) && !(t1 & PORT_SUSPEND)) {
155 set_bit(port, &ehci->bus_suspended);
158 /* enable remote wakeup on all ports */
159 if (device_may_wakeup(&hcd->self.root_hub->dev))
160 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
162 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
165 ehci_vdbg (ehci, "port %d, %08x -> %08x\n",
167 ehci_writel(ehci, t2, reg);
171 /* turn off now-idle HC */
172 del_timer_sync (&ehci->watchdog);
174 hcd->state = HC_STATE_SUSPENDED;
176 /* allow remote wakeup */
178 if (!device_may_wakeup(&hcd->self.root_hub->dev))
180 ehci_writel(ehci, mask, &ehci->regs->intr_enable);
181 ehci_readl(ehci, &ehci->regs->intr_enable);
183 ehci->next_statechange = jiffies + msecs_to_jiffies(10);
184 spin_unlock_irq (&ehci->lock);
189 /* caller has locked the root hub, and should reset/reinit on error */
190 static int ehci_bus_resume (struct usb_hcd *hcd)
192 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
197 if (time_before (jiffies, ehci->next_statechange))
199 spin_lock_irq (&ehci->lock);
201 /* Ideally and we've got a real resume here, and no port's power
202 * was lost. (For PCI, that means Vaux was maintained.) But we
203 * could instead be restoring a swsusp snapshot -- so that BIOS was
204 * the last user of the controller, not reset/pm hardware keeping
205 * state we gave to it.
207 power_okay = ehci_readl(ehci, &ehci->regs->intr_enable);
208 ehci_dbg(ehci, "resume root hub%s\n",
209 power_okay ? "" : " after power loss");
211 /* at least some APM implementations will try to deliver
212 * IRQs right away, so delay them until we're ready.
214 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
216 /* re-init operational registers */
217 ehci_writel(ehci, 0, &ehci->regs->segment);
218 ehci_writel(ehci, ehci->periodic_dma, &ehci->regs->frame_list);
219 ehci_writel(ehci, (u32) ehci->async->qh_dma, &ehci->regs->async_next);
221 /* restore CMD_RUN, framelist size, and irq threshold */
222 ehci_writel(ehci, ehci->command, &ehci->regs->command);
224 /* Some controller/firmware combinations need a delay during which
225 * they set up the port statuses. See Bugzilla #8190. */
228 /* manually resume the ports we suspended during bus_suspend() */
229 i = HCS_N_PORTS (ehci->hcs_params);
231 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
232 temp &= ~(PORT_RWC_BITS
233 | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E);
234 if (test_bit(i, &ehci->bus_suspended) &&
235 (temp & PORT_SUSPEND)) {
236 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
239 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
241 i = HCS_N_PORTS (ehci->hcs_params);
244 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
245 if (test_bit(i, &ehci->bus_suspended) &&
246 (temp & PORT_SUSPEND)) {
247 temp &= ~(PORT_RWC_BITS | PORT_RESUME);
248 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
249 ehci_vdbg (ehci, "resumed port %d\n", i + 1);
252 (void) ehci_readl(ehci, &ehci->regs->command);
254 /* maybe re-activate the schedule(s) */
256 if (ehci->async->qh_next.qh)
258 if (ehci->periodic_sched)
261 ehci->command |= temp;
262 ehci_writel(ehci, ehci->command, &ehci->regs->command);
265 ehci->next_statechange = jiffies + msecs_to_jiffies(5);
266 hcd->state = HC_STATE_RUNNING;
268 /* Now we can safely re-enable irqs */
269 ehci_writel(ehci, INTR_MASK, &ehci->regs->intr_enable);
271 spin_unlock_irq (&ehci->lock);
274 ehci_handover_companion_ports(ehci);
280 #define ehci_bus_suspend NULL
281 #define ehci_bus_resume NULL
283 #endif /* CONFIG_PM */
285 /*-------------------------------------------------------------------------*/
287 /* Display the ports dedicated to the companion controller */
288 static ssize_t show_companion(struct class_device *class_dev, char *buf)
290 struct ehci_hcd *ehci;
291 int nports, index, n;
292 int count = PAGE_SIZE;
295 ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev)));
296 nports = HCS_N_PORTS(ehci->hcs_params);
298 for (index = 0; index < nports; ++index) {
299 if (test_bit(index, &ehci->companion_ports)) {
300 n = scnprintf(ptr, count, "%d\n", index + 1);
309 * Dedicate or undedicate a port to the companion controller.
310 * Syntax is "[-]portnum", where a leading '-' sign means
311 * return control of the port to the EHCI controller.
313 static ssize_t store_companion(struct class_device *class_dev,
314 const char *buf, size_t count)
316 struct ehci_hcd *ehci;
317 int portnum, new_owner, try;
318 u32 __iomem *status_reg;
321 ehci = hcd_to_ehci(bus_to_hcd(class_get_devdata(class_dev)));
322 new_owner = PORT_OWNER; /* Owned by companion */
323 if (sscanf(buf, "%d", &portnum) != 1)
327 new_owner = 0; /* Owned by EHCI */
329 if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params))
331 status_reg = &ehci->regs->port_status[--portnum];
333 set_bit(portnum, &ehci->companion_ports);
335 clear_bit(portnum, &ehci->companion_ports);
338 * The controller won't set the OWNER bit if the port is
339 * enabled, so this loop will sometimes require at least two
340 * iterations: one to disable the port and one to set OWNER.
343 for (try = 4; try > 0; --try) {
344 spin_lock_irq(&ehci->lock);
345 port_status = ehci_readl(ehci, status_reg);
346 if ((port_status & PORT_OWNER) == new_owner
347 || (port_status & (PORT_OWNER | PORT_CONNECT))
351 port_status ^= PORT_OWNER;
352 port_status &= ~(PORT_PE | PORT_RWC_BITS);
353 ehci_writel(ehci, port_status, status_reg);
355 spin_unlock_irq(&ehci->lock);
361 static CLASS_DEVICE_ATTR(companion, 0644, show_companion, store_companion);
363 static inline void create_companion_file(struct ehci_hcd *ehci)
367 /* with integrated TT there is no companion! */
368 if (!ehci_is_TDI(ehci))
369 i = class_device_create_file(ehci_to_hcd(ehci)->self.class_dev,
370 &class_device_attr_companion);
373 static inline void remove_companion_file(struct ehci_hcd *ehci)
375 /* with integrated TT there is no companion! */
376 if (!ehci_is_TDI(ehci))
377 class_device_remove_file(ehci_to_hcd(ehci)->self.class_dev,
378 &class_device_attr_companion);
382 /*-------------------------------------------------------------------------*/
384 static int check_reset_complete (
385 struct ehci_hcd *ehci,
387 u32 __iomem *status_reg,
390 if (!(port_status & PORT_CONNECT)) {
391 ehci->reset_done [index] = 0;
395 /* if reset finished and it's still not enabled -- handoff */
396 if (!(port_status & PORT_PE)) {
398 /* with integrated TT, there's nobody to hand it to! */
399 if (ehci_is_TDI(ehci)) {
401 "Failed to enable port %d on root hub TT\n",
406 ehci_dbg (ehci, "port %d full speed --> companion\n",
409 // what happens if HCS_N_CC(params) == 0 ?
410 port_status |= PORT_OWNER;
411 port_status &= ~PORT_RWC_BITS;
412 ehci_writel(ehci, port_status, status_reg);
415 ehci_dbg (ehci, "port %d high speed\n", index + 1);
420 /*-------------------------------------------------------------------------*/
423 /* build "status change" packet (one or two bytes) from HC registers */
426 ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
428 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
429 u32 temp, status = 0;
431 int ports, i, retval = 1;
434 /* if !USB_SUSPEND, root hub timers won't get shut down ... */
435 if (!HC_IS_RUNNING(hcd->state))
438 /* init status to no-changes */
440 ports = HCS_N_PORTS (ehci->hcs_params);
446 /* Some boards (mostly VIA?) report bogus overcurrent indications,
447 * causing massive log spam unless we completely ignore them. It
448 * may be relevant that VIA VT8235 controlers, where PORT_POWER is
449 * always set, seem to clear PORT_OCC and PORT_CSC when writing to
450 * PORT_POWER; that's surprising, but maybe within-spec.
453 mask = PORT_CSC | PORT_PEC | PORT_OCC;
455 mask = PORT_CSC | PORT_PEC;
456 // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND
458 /* no hub change reports (bit 0) for now (power, ...) */
460 /* port N changes (bit N)? */
461 spin_lock_irqsave (&ehci->lock, flags);
462 for (i = 0; i < ports; i++) {
463 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
466 * Return status information even for ports with OWNER set.
467 * Otherwise khubd wouldn't see the disconnect event when a
468 * high-speed device is switched over to the companion
469 * controller by the user.
472 if (!(temp & PORT_CONNECT))
473 ehci->reset_done [i] = 0;
474 if ((temp & mask) != 0
475 || ((temp & PORT_RESUME) != 0
476 && time_after_eq(jiffies,
477 ehci->reset_done[i]))) {
479 buf [0] |= 1 << (i + 1);
481 buf [1] |= 1 << (i - 7);
485 /* FIXME autosuspend idle root hubs */
486 spin_unlock_irqrestore (&ehci->lock, flags);
487 return status ? retval : 0;
490 /*-------------------------------------------------------------------------*/
493 ehci_hub_descriptor (
494 struct ehci_hcd *ehci,
495 struct usb_hub_descriptor *desc
497 int ports = HCS_N_PORTS (ehci->hcs_params);
500 desc->bDescriptorType = 0x29;
501 desc->bPwrOn2PwrGood = 10; /* ehci 1.0, 2.3.9 says 20ms max */
502 desc->bHubContrCurrent = 0;
504 desc->bNbrPorts = ports;
505 temp = 1 + (ports / 8);
506 desc->bDescLength = 7 + 2 * temp;
508 /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
509 memset (&desc->bitmap [0], 0, temp);
510 memset (&desc->bitmap [temp], 0xff, temp);
512 temp = 0x0008; /* per-port overcurrent reporting */
513 if (HCS_PPC (ehci->hcs_params))
514 temp |= 0x0001; /* per-port power control */
516 temp |= 0x0002; /* no power switching */
518 // re-enable when we support USB_PORT_FEAT_INDICATOR below.
519 if (HCS_INDICATOR (ehci->hcs_params))
520 temp |= 0x0080; /* per-port indicators (LEDs) */
522 desc->wHubCharacteristics = (__force __u16)cpu_to_le16 (temp);
525 /*-------------------------------------------------------------------------*/
527 #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
529 static int ehci_hub_control (
537 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
538 int ports = HCS_N_PORTS (ehci->hcs_params);
539 u32 __iomem *status_reg = &ehci->regs->port_status[
540 (wIndex & 0xff) - 1];
547 * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR.
548 * HCS_INDICATOR may say we can change LEDs to off/amber/green.
549 * (track current state ourselves) ... blink for diagnostics,
550 * power, "this is the one", etc. EHCI spec supports this.
553 spin_lock_irqsave (&ehci->lock, flags);
555 case ClearHubFeature:
557 case C_HUB_LOCAL_POWER:
558 case C_HUB_OVER_CURRENT:
559 /* no hub-wide feature/status flags */
565 case ClearPortFeature:
566 if (!wIndex || wIndex > ports)
569 temp = ehci_readl(ehci, status_reg);
572 * Even if OWNER is set, so the port is owned by the
573 * companion controller, khubd needs to be able to clear
574 * the port-change status bits (especially
575 * USB_PORT_FEAT_C_CONNECTION).
579 case USB_PORT_FEAT_ENABLE:
580 ehci_writel(ehci, temp & ~PORT_PE, status_reg);
582 case USB_PORT_FEAT_C_ENABLE:
583 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_PEC,
586 case USB_PORT_FEAT_SUSPEND:
587 if (temp & PORT_RESET)
589 if (ehci->no_selective_suspend)
591 if (temp & PORT_SUSPEND) {
592 if ((temp & PORT_PE) == 0)
594 /* resume signaling for 20 msec */
595 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
596 ehci_writel(ehci, temp | PORT_RESUME,
598 ehci->reset_done [wIndex] = jiffies
599 + msecs_to_jiffies (20);
602 case USB_PORT_FEAT_C_SUSPEND:
603 /* we auto-clear this feature */
605 case USB_PORT_FEAT_POWER:
606 if (HCS_PPC (ehci->hcs_params))
608 temp & ~(PORT_RWC_BITS | PORT_POWER),
611 case USB_PORT_FEAT_C_CONNECTION:
612 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_CSC,
615 case USB_PORT_FEAT_C_OVER_CURRENT:
616 ehci_writel(ehci, (temp & ~PORT_RWC_BITS) | PORT_OCC,
619 case USB_PORT_FEAT_C_RESET:
620 /* GetPortStatus clears reset */
625 ehci_readl(ehci, &ehci->regs->command); /* unblock posted write */
627 case GetHubDescriptor:
628 ehci_hub_descriptor (ehci, (struct usb_hub_descriptor *)
632 /* no hub-wide feature/status flags */
634 //cpu_to_le32s ((u32 *) buf);
637 if (!wIndex || wIndex > ports)
641 temp = ehci_readl(ehci, status_reg);
645 status |= 1 << USB_PORT_FEAT_C_CONNECTION;
647 status |= 1 << USB_PORT_FEAT_C_ENABLE;
648 if ((temp & PORT_OCC) && !ignore_oc)
649 status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT;
651 /* whoever resumes must GetPortStatus to complete it!! */
652 if (temp & PORT_RESUME) {
654 /* Remote Wakeup received? */
655 if (!ehci->reset_done[wIndex]) {
656 /* resume signaling for 20 msec */
657 ehci->reset_done[wIndex] = jiffies
658 + msecs_to_jiffies(20);
659 /* check the port again */
660 mod_timer(&ehci_to_hcd(ehci)->rh_timer,
661 ehci->reset_done[wIndex]);
664 /* resume completed? */
665 else if (time_after_eq(jiffies,
666 ehci->reset_done[wIndex])) {
667 status |= 1 << USB_PORT_FEAT_C_SUSPEND;
668 ehci->reset_done[wIndex] = 0;
670 /* stop resume signaling */
671 temp = ehci_readl(ehci, status_reg);
673 temp & ~(PORT_RWC_BITS | PORT_RESUME),
675 retval = handshake(ehci, status_reg,
676 PORT_RESUME, 0, 2000 /* 2msec */);
679 "port %d resume error %d\n",
683 temp &= ~(PORT_SUSPEND|PORT_RESUME|(3<<10));
687 /* whoever resets must GetPortStatus to complete it!! */
688 if ((temp & PORT_RESET)
689 && time_after_eq(jiffies,
690 ehci->reset_done[wIndex])) {
691 status |= 1 << USB_PORT_FEAT_C_RESET;
692 ehci->reset_done [wIndex] = 0;
694 /* force reset to complete */
695 ehci_writel(ehci, temp & ~(PORT_RWC_BITS | PORT_RESET),
697 /* REVISIT: some hardware needs 550+ usec to clear
698 * this bit; seems too long to spin routinely...
700 retval = handshake(ehci, status_reg,
703 ehci_err (ehci, "port %d reset error %d\n",
708 /* see what we found out */
709 temp = check_reset_complete (ehci, wIndex, status_reg,
710 ehci_readl(ehci, status_reg));
713 /* transfer dedicated ports to the companion hc */
714 if ((temp & PORT_CONNECT) &&
715 test_bit(wIndex, &ehci->companion_ports)) {
716 temp &= ~PORT_RWC_BITS;
718 ehci_writel(ehci, temp, status_reg);
719 ehci_dbg(ehci, "port %d --> companion\n", wIndex + 1);
720 temp = ehci_readl(ehci, status_reg);
724 * Even if OWNER is set, there's no harm letting khubd
725 * see the wPortStatus values (they should all be 0 except
726 * for PORT_POWER anyway).
729 if (temp & PORT_CONNECT) {
730 status |= 1 << USB_PORT_FEAT_CONNECTION;
731 // status may be from integrated TT
732 status |= ehci_port_speed(ehci, temp);
735 status |= 1 << USB_PORT_FEAT_ENABLE;
736 if (temp & (PORT_SUSPEND|PORT_RESUME))
737 status |= 1 << USB_PORT_FEAT_SUSPEND;
739 status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
740 if (temp & PORT_RESET)
741 status |= 1 << USB_PORT_FEAT_RESET;
742 if (temp & PORT_POWER)
743 status |= 1 << USB_PORT_FEAT_POWER;
745 #ifndef EHCI_VERBOSE_DEBUG
746 if (status & ~0xffff) /* only if wPortChange is interesting */
748 dbg_port (ehci, "GetStatus", wIndex + 1, temp);
749 put_unaligned(cpu_to_le32 (status), (__le32 *) buf);
753 case C_HUB_LOCAL_POWER:
754 case C_HUB_OVER_CURRENT:
755 /* no hub-wide feature/status flags */
762 selector = wIndex >> 8;
764 if (!wIndex || wIndex > ports)
767 temp = ehci_readl(ehci, status_reg);
768 if (temp & PORT_OWNER)
771 temp &= ~PORT_RWC_BITS;
773 case USB_PORT_FEAT_SUSPEND:
774 if (ehci->no_selective_suspend)
776 if ((temp & PORT_PE) == 0
777 || (temp & PORT_RESET) != 0)
779 if (device_may_wakeup(&hcd->self.root_hub->dev))
780 temp |= PORT_WAKE_BITS;
781 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
783 case USB_PORT_FEAT_POWER:
784 if (HCS_PPC (ehci->hcs_params))
785 ehci_writel(ehci, temp | PORT_POWER,
788 case USB_PORT_FEAT_RESET:
789 if (temp & PORT_RESUME)
791 /* line status bits may report this as low speed,
792 * which can be fine if this root hub has a
793 * transaction translator built in.
795 if ((temp & (PORT_PE|PORT_CONNECT)) == PORT_CONNECT
796 && !ehci_is_TDI(ehci)
797 && PORT_USB11 (temp)) {
799 "port %d low speed --> companion\n",
803 ehci_vdbg (ehci, "port %d reset\n", wIndex + 1);
808 * caller must wait, then call GetPortStatus
809 * usb 2.0 spec says 50 ms resets on root
811 ehci->reset_done [wIndex] = jiffies
812 + msecs_to_jiffies (50);
814 ehci_writel(ehci, temp, status_reg);
817 /* For downstream facing ports (these): one hub port is put
818 * into test mode according to USB2 11.24.2.13, then the hub
819 * must be reset (which for root hub now means rmmod+modprobe,
820 * or else system reboot). See EHCI 2.3.9 and 4.14 for info
821 * about the EHCI-specific stuff.
823 case USB_PORT_FEAT_TEST:
824 if (!selector || selector > 5)
828 temp |= selector << 16;
829 ehci_writel(ehci, temp, status_reg);
835 ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */
840 /* "stall" on error */
843 spin_unlock_irqrestore (&ehci->lock, flags);