|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 L0 ^# r5 s. G' a0 u$ g! Y#include <linux/init.h>- D/ ]. A9 B9 A( h5 t
#include <linux/module.h>
6 J5 E$ l3 s8 C- ?+ S# t9 s9 l#include <linux/kernel.h>
; z9 O: `; f. V% R#include <linux/types.h>
5 O$ }4 p( B( m* H* _8 }#include <linux/gpio.h>& u1 B7 U$ H0 p d
#include <linux/leds.h>+ T8 B1 q- Q: X, E; |3 W
#include <linux/platform_device.h>
X# E! Y9 [" ~/ w1 ~- L
/ L5 e& }1 J% V8 _#include <asm/mach-types.h>$ @: x7 }5 b+ V% V7 T2 Q
#include <asm/mach/arch.h>
# `$ l5 N+ W+ Q7 c#include <mach/da8xx.h>- @/ ^! Y' M2 u$ g
#include <mach/mux.h>
: ]: d! I. M* i" M, T
- O; G! `% v7 p8 ~2 }# {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" d" x4 n/ \/ d1 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- O" U5 {- k- X4 c. e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 C& X$ K( ?) f$ h( {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 i3 e# C% q$ S' l4 C( _1 T
- W' W" T, _2 R' v$ q% R/* assign the tl som board LED-GPIOs*/1 |* v0 _' `) H% j; U/ R
static const short da850_evm_tl_user_led_pins[] = {! V* d1 h7 H+ s! c; t3 W# b3 s
/* These pins are definition at <mach/mux.h> file */
1 g. S1 b( p" e& z8 J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# d2 F; J7 d3 ~ G -17 t# \% t% _7 n
};
) a' e+ |) D! E% P& U! f" W% O Z' D$ a0 t/ J L
static struct gpio_led da850_evm_tl_leds[] = {
0 V7 A, U: o, w, ]( J6 a {
$ V0 f' H% {3 p+ x& _0 g% P .active_low = 0,! x' X, k a! e
.gpio = DA850_USER_LED0,* t4 M- U: C( [/ R" t
.name = "user_led0",
) ~5 `* O9 X/ r j7 k .default_trigger = "default-on",
/ N( f1 V/ R0 t+ I },/ _" G. Q0 Y0 j. q
{
! J6 W2 _0 Z9 j; r, F; _ .active_low = 0,# a7 R$ C! E6 H, }9 p9 V5 h
.gpio = DA850_USER_LED1,' u: m/ v; v, Y7 `7 C1 k
.name = "user_led1",
. T* b+ t8 B* g% |' e .default_trigger = "default-on",
/ T1 K. Q- s9 b: l },( K* L6 M% y4 s0 |4 Q; K1 Q& d
{
% \: x3 S9 e: [- Y6 H+ Y .active_low = 0,2 t- I3 \6 m3 F, [! B- Q; U7 _7 C2 z
.gpio = DA850_USER_LED2," H# d( [5 M' N: K
.name = "user_led2",4 @; @- I' R) ~# d9 }% X. L
.default_trigger = "default-on",2 [0 s3 f [, d4 A' o+ p% y
},
/ v. N, a* F- K- T6 B {
6 V9 J& [/ \& ^& O .active_low = 0,
5 W1 x ?, E4 H) Y9 c .gpio = DA850_USER_LED3,) z! i! h9 P% a0 N
.name = "user_led3",7 g# n8 k d6 C8 Z6 g
.default_trigger = "default-on",
' W; ]6 T: G" p3 ]# k },0 z3 Y; a: E0 c8 `1 Y% w; A) r
};% Q; M& o' b9 Q2 r- ^2 d1 T
9 e- z( f8 h: V8 Z( D' j( T: r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ {3 o$ _4 L- U: b7 W9 q& o7 R .leds = da850_evm_tl_leds,' K, ^2 H7 [$ \. P9 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),( p& a; h9 w0 G; l% N% @" p% u4 o% q
};% s4 s+ [5 |( ]
9 c* n' f5 K* P1 J' Sstatic void led_dev_release(struct device *dev)1 n- {+ @+ d! _6 B! R
{
3 C6 Q L9 S. v6 q& O};
9 a6 b1 O, ^( p( Q' B2 ~7 [" I
; A h1 j* w, z k- g- jstatic struct platform_device da850_evm_tl_leds_device = {
+ j3 R0 R! \7 [) b2 f& ]) l .name = "leds-gpio",
8 r! D: U5 D$ _8 l; R .id = 1,
3 o' p: j4 N7 e- U) G |" _ .dev = {3 a6 Z X$ F8 y3 {4 y
.platform_data = &da850_evm_tl_leds_pdata,
% w6 P* Z' E% X* |+ c2 Y3 N9 x .release = led_dev_release,
0 x. X+ K" D. _1 _2 e: W }8 X: T7 d. a+ p# ^
};# P2 D- J# O/ x, f- ]7 u% |( @
8 P$ R1 X6 F$ @; M* K* ]0 A, O: cstatic int __init led_platform_init(void)
0 F* s; o/ G6 E- j{2 m- ^# ~+ _$ ~2 s
int ret;& W5 ^1 Y( H' J. \$ }+ C2 B" O' h
#if 0
+ a' p. }9 ^* f, o- t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; K& ^, Q! \5 `/ K2 G! Q* N
if (ret)
. [! t9 p/ l0 p' v( ]3 Z# I' A/ Q pr_warning("da850_evm_tl_leds_init : User LED mux failed :") m! T8 y+ z# U" ]; r
"%d\n", ret);+ Z& \ y1 r" k; d$ G
#endif
0 F) h3 N4 o2 F% I! W ret = platform_device_register(&da850_evm_tl_leds_device);
) R* w8 T" S4 _: P1 V if (ret)
* Z* W z, {1 A, t6 j" o pr_warning("Could not register som GPIO expander LEDS");$ f9 t* L- H9 {$ U8 o: k
else
; ^2 v- x* A7 B3 Z# W printk(KERN_INFO "LED register sucessful!\n");8 M( L+ J/ M/ d# K
7 g9 P: U3 c3 g: F/ d! \. D return ret;% c. N$ z- Z- z5 \
}
, k! n/ V1 K9 W( u% V' t4 w) O# A; T, x* y- w$ r4 W5 m
static void __exit led_platform_exit(void)/ ?4 X, Q9 p, x+ u: W
{6 k$ ^9 A$ n1 t3 x* S0 s
platform_device_unregister(&da850_evm_tl_leds_device);8 Y5 c& N3 N4 I9 K' G8 }3 ~' o
6 B6 p! w5 g8 f8 O2 K
printk(KERN_INFO "LED unregister!\n");0 c3 f3 D. \+ l9 O& W7 k G
}
" u3 S/ A6 m% w- L* E; R! i$ A7 b# n3 n1 r
module_init(led_platform_init);
2 D5 ]+ }4 N+ y. y' A$ G Hmodule_exit(led_platform_exit); Z/ Z; \7 _+ t
/ e8 t0 O8 E! M: ]MODULE_DESCRIPTION("Led platform driver");
, d1 a8 C& J! w/ [MODULE_AUTHOR("Tronlong");
0 k; J8 [9 I* A0 }$ r' @8 _MODULE_LICENSE("GPL");: ]: ]8 Q" O% W# n- E1 o1 Z
& z. n) J6 B; f/ J
|
|