|
求大神给下面的程序做注解,请稍详细些,谢谢。! \3 }% H Y6 t+ U- H
#include <linux/init.h>: A7 j% @8 x; h; H
#include <linux/module.h>
4 ]/ v9 M% x7 ~, q9 u#include <linux/kernel.h>$ n v$ T% e* U
#include <linux/types.h>
) L6 a3 g! q' G#include <linux/gpio.h>& n: J6 S* F% X0 {' `9 a
#include <linux/leds.h>' Z9 z7 w: w( J; I; f; R
#include <linux/platform_device.h>
" |% @: G3 |/ }
. K9 k1 D& c) S, @#include <asm/mach-types.h>
& g! K C1 x' l0 u#include <asm/mach/arch.h>
4 \) _8 M% u3 I7 b( F: {4 K#include <mach/da8xx.h>
! I: }" }, l( j5 ~& y0 M+ a+ N1 M#include <mach/mux.h>3 S9 l" q9 r/ f
; @& g$ ^# H' x% z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 ?$ r) b6 g6 |$ P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 i$ s* {. D& Z, Q6 Y7 s: i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); u# L' }% W# d( n+ y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 f; O# I8 B0 {
8 ]: x+ t7 s% k a/* assign the tl som board LED-GPIOs*/
& { O2 j, n4 ]# N8 kstatic const short da850_evm_tl_user_led_pins[] = {
0 |& K5 J9 K$ V, D$ O /* These pins are definition at <mach/mux.h> file */3 O$ h: L& ^; n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) k) g0 ]3 r$ r0 A9 ?6 F4 T& D+ Z -18 z& `( w& A; O, q, L3 C# z- w
};
9 x" I, e6 F" S. O4 M9 d- ]9 s2 r# H$ T( u$ `/ F6 l; V: x
static struct gpio_led da850_evm_tl_leds[] = {# N7 p! a! B6 f' S% S/ C
{
8 ^/ f7 v ~3 w" S# G( O/ i .active_low = 0,. i' i0 s) m3 s& o) B
.gpio = DA850_USER_LED0,
! |( L7 K; z' D2 c- | .name = "user_led0",6 i$ |3 A7 l" u4 W2 d- R$ _
.default_trigger = "default-on",
7 D7 q& o2 w! k. h6 X! j9 b+ J },
. k2 U" }5 p3 I) } {% }9 \! [% R5 O% b/ x. h' ]$ I
.active_low = 0,
5 V* k$ K3 M% p* P: I! q .gpio = DA850_USER_LED1,: n& v G$ C4 q: C
.name = "user_led1",
- C+ F" A! |4 z- X .default_trigger = "default-on",7 d4 `& w% c O& q5 R8 {/ ~
},) h6 U- z$ R) U9 _, z9 |
{% {' x8 Q/ J6 ]1 s: x6 w, P7 v0 \) p
.active_low = 0,
& d2 u0 V+ H* g2 L$ o Q" j .gpio = DA850_USER_LED2,
/ d( w" v9 L8 m$ N% f$ `& C .name = "user_led2",
: y' u2 c% Y6 [2 ^0 W .default_trigger = "default-on",
4 q/ [1 X, L+ ]3 t },4 r+ u! p9 h- c# M
{
8 p1 q+ p2 F# ~ v5 x9 H .active_low = 0,! k6 C4 W) U. o5 r% n. ^' P( J8 u
.gpio = DA850_USER_LED3,
4 u4 r8 B$ l3 E% \4 s/ l+ e, [ .name = "user_led3",+ w0 R$ N( f/ q7 l+ x% O
.default_trigger = "default-on",
r- T( }* K' M& B6 j },
. Q9 R8 ?2 V/ F; H2 @( o4 V6 I/ F};
9 n' a, b+ j D- P5 ]$ S2 Q0 b# h
4 k" b& z" y6 e) o" s" ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 G A" }, a; v7 k .leds = da850_evm_tl_leds,
) n- B& _0 ~# f1 k7 s- o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& f1 R$ T& O. X
};
0 _5 O4 d1 ^/ F! Z9 A! N! W/ ^& f7 _+ _$ u
static void led_dev_release(struct device *dev) |: T" W' _: I, ?
{
2 n" X% A3 R% X' D/ T}; I. K% R! X; O2 Y
, H K8 J# }0 W: y P
static struct platform_device da850_evm_tl_leds_device = {) G* D0 X* ?, _( p7 O& o
.name = "leds-gpio",6 E& N/ l+ G0 y
.id = 1,1 `" V- E, [8 k" m/ {/ m) q5 o; V6 W
.dev = {
+ r% j. |2 U7 C .platform_data = &da850_evm_tl_leds_pdata,
* l6 _0 d J" r, Y- Z .release = led_dev_release,
* i4 _* d$ ^# |5 B. n }
1 I. J. T3 U, h3 |};7 T* J4 f2 h. _
/ b; z; H5 M2 u" {
static int __init led_platform_init(void). @5 d2 p/ ?5 Y# i
{
5 J7 i( Y0 N, J! N/ Z) v' k3 B9 F int ret;# H B# g' [4 H) y1 d0 O$ t
#if 0
9 {% @. R0 D+ z) x8 [; k8 E) t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) u, ]$ r. m5 u L4 ?. S if (ret)2 i# |# D. c9 X2 p1 |+ ]( ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& W) r' p# F+ g6 o0 `0 u1 R
"%d\n", ret);
8 N! H, x7 b4 u#endif7 o7 j. ?7 i' B. n
ret = platform_device_register(&da850_evm_tl_leds_device);
) b% l) O3 Z# C& ]+ b/ A9 {) V e if (ret)8 B, u; A6 j7 N
pr_warning("Could not register som GPIO expander LEDS");
$ E' | w- ]. r! b2 j n' e. T" G else
C- y: j8 V* u/ ] printk(KERN_INFO "LED register sucessful!\n");% o! v! B U$ M0 w& J
/ W" w, u. g5 g0 d
return ret;/ @' t! ~4 P$ v: Y5 v$ N6 {" l. [( ^
}. P8 B. U4 Q" M
1 A- W& c N* K7 N" u- m$ qstatic void __exit led_platform_exit(void)
5 c G: A7 L/ _9 f{
4 L2 h1 v. H4 _4 v) y platform_device_unregister(&da850_evm_tl_leds_device);
! C6 n* J) w- a$ R
5 A% C, Z" G' J' f printk(KERN_INFO "LED unregister!\n");
9 S4 x6 r3 u0 ^- T* ~$ [! ^}
) h/ ]4 a( ^$ A$ G: p' `9 Z: A( | D
module_init(led_platform_init);
; T; P& o4 b3 ~' gmodule_exit(led_platform_exit);1 t1 C7 C4 E+ {$ E
8 h# N* z. Q# H) |9 n: C \
MODULE_DESCRIPTION("Led platform driver");
- A" v! O- i" B2 ^0 MMODULE_AUTHOR("Tronlong");0 k! v7 H9 [" \" O }- ]
MODULE_LICENSE("GPL");2 M" D- s. a" v4 d, e
0 z! G" u3 a. c: Y& \8 }" Z
|
|